def test_owner_type(self): org = Organization(id=123, mnemonic='org') user = UserProfile(id=123, username='******') self.assertIsNone(Mapping().owner_type) self.assertEqual(Mapping(parent=Source(organization=org)).owner_type, 'Organization') self.assertEqual(Mapping(parent=Source(user=user)).owner_type, 'User')
def test_public_sources(self, source_set_mock): source_set_mock.exclude = Mock(return_value=Mock(filter=Mock(return_value=Mock(count=Mock(return_value=10))))) self.assertEqual(UserProfile().public_sources, 10) source_set_mock.exclude.assert_called_once_with(public_access=ACCESS_TYPE_NONE) source_set_mock.exclude().filter.assert_called_once_with(version=HEAD) source_set_mock.exclude().filter().count.assert_called_once()
def test_owner(self): org = Organization(id=123) user = UserProfile(id=123) self.assertIsNone(Mapping().owner) self.assertEqual(Mapping(parent=Source(organization=org)).owner, org) self.assertEqual(Mapping(parent=Source(user=user)).owner, user)
def test_email_verification_url(self): user = UserProfile(id=189, username='******', verification_token='some-token') self.assertEqual( user.email_verification_url, 'http://localhost:4000/#/accounts/foobar/verify/some-token/')
def test_reset_password_url(self): user = UserProfile(id=189, username='******', verification_token='some-token') self.assertEqual( user.reset_password_url, 'http://localhost:4000/#/accounts/foobar/password/reset/some-token/' )
def test_create_userprofile_positive(self): self.assertFalse(UserProfile.objects.filter(username='******').exists()) user = UserProfile( username='******', email='*****@*****.**', last_name='Schindler', first_name='Oskar', password='******', ) user.full_clean() user.save() user.organizations.add(self.org) self.assertIsNotNone(user.id) self.assertEqual(user.username, user.mnemonic) self.assertTrue(UserProfile.objects.filter(username='******').exists())
def test_user(self): self.assertEqual(UserProfile().user, '') self.assertEqual(UserProfile(username='******').user, 'foo')
def test_mnemonic(self): self.assertEqual(UserProfile().mnemonic, '') self.assertEqual(UserProfile(username='******').mnemonic, 'foo')
def test_resource_type(self): user = UserProfile() self.assertEqual(user.resource_type, USER_OBJECT_TYPE)
def test_full_name(self): self.assertEqual( UserProfile(first_name='First', last_name="Last").full_name, "First Last" )
def test_send_reset_password_email(self, mail_mock): # pylint: disable=no-self-use user = UserProfile(id=189) user.send_reset_password_email() mail_mock.apply_async.assert_called_once_with((189, ))
def test_send_verification_email(self, mail_mock): # pylint: disable=no-self-use user = UserProfile(id=189) user.send_verification_email() mail_mock.delay.assert_called_once_with(189)