示例#1
0
 def test_user_edit_duplicate_email(self):
     user = CtsUserFactory()
     user2 = CtsUserFactory()
     data = model_to_dict(user)
     data['email'] = user2.email
     form = CtsUserEditForm(instance=user, data=data)
     self.assertFalse(form.is_valid())
     self.assertIn('email', form.errors)
示例#2
0
    def test_user_edit(self):
        user = CtsUserFactory()

        data = model_to_dict(user)
        data['mobile'] = '+1134234'
        form = CtsUserEditForm(instance=user, data=data)
        self.assertTrue(form.is_valid())
        user = form.save()
        user = CtsUser.objects.get(pk=user.pk)
        self.assertEqual(data['mobile'], user.mobile)