'Ensure password history is created for all users without existing history.'

def test_set_history_multiple(self):

    self.UserModel.objects.create_user(username='second')
    self.UserModel.objects.create_user(username='third')
    password_age = 5
    out = StringIO()
    call_command('user_password_history', '--days={}'.format(password_age), stdout=out)
    user = self.UserModel.objects.get(username='patrick')
    password_history = user.password_history.all()
    self.assertEqual(password_history.count(), 1)
    first_timestamp = password_history[0].timestamp
    user = self.UserModel.objects.get(username='second')
    password_history = user.password_history.all()
    self.assertEqual(password_history.count(), 1)
    second_timestamp = password_history[0].timestamp
    self.assertEqual(first_timestamp, second_timestamp)
    user = self.UserModel.objects.get(username='third')
    password_history = user.password_history.all()
    self.assertEqual(password_history.count(), 1)
    third_timestamp = password_history[0].timestamp
    self.assertEqual(first_timestamp, third_timestamp)
    self.assertIn('Password    history    set    to    ', out.getvalue())
    self.assertIn('for    {}    users'.format(3), out.getvalue())
