示例#1
0
    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')
示例#2
0
    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()
示例#3
0
    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)
示例#4
0
 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/')
示例#5
0
 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/'
     )
示例#6
0
    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())
示例#7
0
 def test_user(self):
     self.assertEqual(UserProfile().user, '')
     self.assertEqual(UserProfile(username='******').user, 'foo')
示例#8
0
 def test_mnemonic(self):
     self.assertEqual(UserProfile().mnemonic, '')
     self.assertEqual(UserProfile(username='******').mnemonic, 'foo')
示例#9
0
    def test_resource_type(self):
        user = UserProfile()

        self.assertEqual(user.resource_type, USER_OBJECT_TYPE)
示例#10
0
 def test_full_name(self):
     self.assertEqual(
         UserProfile(first_name='First', last_name="Last").full_name,
         "First Last"
     )
示例#11
0
    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, ))
示例#12
0
    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)