def test_can_create_mandragore_user(self): self.assertTrue( can_create_mandragore_user( "new username !!", "dummy mandragore id!", ), "We should be able to create a mandragore user for a nonexistent username and nonexistent mandragore id" # noqa ) self.assertFalse( can_create_mandragore_user( self.user.username, "dummy mandragore id!", ), "We should not be able to create a mandragore user for an existing username" ) create_mandragore_profile_for_user("12345", self.user) self.assertFalse( can_create_mandragore_user( "dummy user", "12345" ), "We should not be able to create a mandragore user for an existing mandragore id" )
def test_user_coherent_with_mandragore(self): # Create a fake mandragore user mandragore_user = User( first_name="Karl", last_name="Marx", username="******", email="*****@*****.**", ) mandragore_user.save() mandragoreprofile = create_mandragore_profile_for_user( '1234', mandragore_user ) mandragoreprofile.save() self.assertTrue( user_coherent_with_mandragore( mandragore_user, { 'person_id': '1234', 'username': '******', 'email': '*****@*****.**', } ) )
def test_get_mandragore_user(self): # A user with no profile should raise the error with self.assertRaises(MandragoreError): get_mandragore_user(self.user.username) create_mandragore_profile_for_user("1234", self.user) # Validating with a different person_id should raise the error with self.assertRaises(MandragoreError): get_mandragore_user(self.user.username, person_id="123456") user = get_mandragore_user(self.user.username, person_id="1234") self.assertEquals( user.pk, self.user.pk )
def test_create_mandragore_profile_for_user(self): mandragore_profile = create_mandragore_profile_for_user( 9001, self.user ) self.assertTrue( mandragore_profile.synced_with_origin )