Ejemplo n.º 1
0
    def test_autovouch_email(self):
        """Users with emails in AUTO_VOUCH_DOMAINS should be vouched."""
        auto_user = user(email="*****@*****.**")
        auto_profile = auto_user.get_profile()
        auto_profile.save()
        assert auto_profile.is_vouched, "Profile should be vouched."
        assert auto_profile.vouched_by is None, "Profile should not have a voucher."

        non_auto_user = user()
        non_auto_profile = non_auto_user.get_profile()
        non_auto_profile.save()
        assert not non_auto_profile.is_vouched, "Profile should not be vouched."
Ejemplo n.º 2
0
    def test_autovouch_email(self):
        """Users with emails in AUTO_VOUCH_DOMAINS should be vouched."""
        auto_user = user(email='*****@*****.**')
        auto_profile = auto_user.get_profile()
        auto_profile.save()
        assert auto_profile.is_vouched, 'Profile should be vouched.'
        assert auto_profile.vouched_by is None, (
            'Profile should not have a voucher.')

        non_auto_user = user()
        non_auto_profile = non_auto_user.get_profile()
        non_auto_profile.save()
        assert not non_auto_profile.is_vouched, (
            'Profile should not be vouched.')
Ejemplo n.º 3
0
 def test_not_list(self):
     """Test incomplete profile group listing."""
     u = user()
     u.userprofile.groups.add(Group.objects.get(name='staff'))
     response = self.mozillian_client.get(
         reverse('group', kwargs={'url': 'staff'}), follow=True)
     eq_(len(response.context['people']), 0,
         'Mozillians with incomplete profile get listed in groups.')
Ejemplo n.º 4
0
 def test_no_profile_page(self):
     """Test incomplete profile no profile page."""
     u = user()
     response = self.mozillian_client.get(
         reverse('profile', kwargs={'username': u.username}),
         follow=True)
     eq_(response.status_code, 404,
         'Incomplete profile has a profile page.')
Ejemplo n.º 5
0
 def test_has_country(self):
     u = user(username='******', full_name='sam')
     p = u.get_profile()
     p.country = 'us'
     p.save()
     assert self.client.login(email=u.email)
     r = self.client.get(reverse('profile', args=[u.username]), follow=True)
     self.assertContains(r, '<dt>Location</dt>')
Ejemplo n.º 6
0
 def test_has_country(self):
     u = user(username='******', full_name='sam')
     p = u.get_profile()
     p.country = 'us'
     p.save()
     assert self.client.login(email=u.email)
     r = self.client.get(reverse('profile', args=[u.username]), follow=True)
     self.assertContains(r, '<dt>Location</dt>')
Ejemplo n.º 7
0
 def test_has_region(self):
     u = user(username='******', full_name='sam')
     p = u.get_profile()
     p.country = 'us'
     p.region = 'New York'
     p.save()
     assert self.client.login(email=u.email)
     r = self.client.get(reverse('profile', args=[u.username]), follow=True)
     self.assertContains(r, p.region)
Ejemplo n.º 8
0
 def test_has_region(self):
     u = user(username='******', full_name='sam')
     p = u.get_profile()
     p.country = 'us'
     p.region = 'New York'
     p.save()
     assert self.client.login(email=u.email)
     r = self.client.get(reverse('profile', args=[u.username]), follow=True)
     self.assertContains(r, p.region)
Ejemplo n.º 9
0
    def test_only_autovouch_in_staff(self):
        """Restrict the staff group to emails in AUTO_VOUCH_DOMAINS."""
        staff = Group.objects.get_or_create(name="staff", system=True)[0]
        staff_user = user(email="*****@*****.**")
        staff_profile = staff_user.get_profile()
        staff_profile.save()
        assert staff in staff_profile.groups.all(), "Auto-vouched email in staff group by default."

        staff_profile.groups.remove(staff)
        staff_profile.save()
        assert staff in staff_profile.groups.all(), "Auto-vouched email cannot be removed from staff group."

        community_user = user()
        community_profile = community_user.get_profile()
        community_profile.save()
        assert staff not in community_profile.groups.all(), "Non-auto-vouched email not automatically in staff group."

        community_profile.groups.add(staff)
        community_profile.save()
        assert staff not in community_profile.groups.all(), "Non-auto-vouched email cannot be added to staff group."
Ejemplo n.º 10
0
 def setUp(self):
     self.data = {'country': 'us',
                  'region': 'California',
                  'city': 'Mountain View',
                  'ircname': 'hax0r',
                  'bio': 'I love ice cream. I code. I tweet.',
                  'full_name': 'Nikos Koukos'}
     self.auto_user = user()
     self.up = self.auto_user.userprofile
     for key, value in self.data.iteritems():
         setattr(self.up, key, value)
     self.up.is_vouched = True
     self.up.save()
Ejemplo n.º 11
0
 def setUp(self):
     self.data = {
         'country': 'us',
         'region': 'California',
         'city': 'Mountain View',
         'ircname': 'hax0r',
         'bio': 'I love ice cream. I code. I tweet.',
         'full_name': 'Nikos Koukos'
     }
     self.auto_user = user()
     self.up = self.auto_user.userprofile
     for key, value in self.data.iteritems():
         setattr(self.up, key, value)
     self.up.is_vouched = True
     self.up.save()
Ejemplo n.º 12
0
    def test_only_autovouch_in_staff(self):
        """Restrict the staff group to emails in AUTO_VOUCH_DOMAINS."""
        staff = Group.objects.get_or_create(name='staff', system=True)[0]
        staff_user = user(email='*****@*****.**')
        staff_profile = staff_user.get_profile()
        staff_profile.save()
        assert staff in staff_profile.groups.all(), (
            'Auto-vouched email in staff group by default.')

        staff_profile.groups.remove(staff)
        staff_profile.save()
        assert staff in staff_profile.groups.all(), (
            'Auto-vouched email cannot be removed from staff group.')

        community_user = user()
        community_profile = community_user.get_profile()
        community_profile.save()
        assert staff not in community_profile.groups.all(), (
            'Non-auto-vouched email not automatically in staff group.')

        community_profile.groups.add(staff)
        community_profile.save()
        assert staff not in community_profile.groups.all(), (
            'Non-auto-vouched email cannot be added to staff group.')
Ejemplo n.º 13
0
    def test_username_filled_in(self):
        """The username field should have a type and value."""
        newbie = user(username="******", email="*****@*****.**")

        url = reverse("profile.edit")
        assert self.client.login(email=newbie.email)
        response = self.client.get(url, follow=True)

        eq_(200, response.status_code)
        doc = pq(response.content)
        field = doc("#id_username")[0]
        eq_("input", field.tag)
        assert "value" in field.attrib
        eq_("text", field.attrib["type"])
        eq_(newbie.username, field.attrib["value"])
Ejemplo n.º 14
0
 def setUp(self):
     self.data = {
         "country": "us",
         "region": "California",
         "city": "Mountain View",
         "ircname": "hax0r",
         "bio": "I love ice cream. I code. I tweet.",
         "full_name": "Nikos Koukos",
     }
     self.auto_user = user()
     self.up = self.auto_user.userprofile
     for key, value in self.data.iteritems():
         setattr(self.up, key, value)
     self.up.is_vouched = True
     self.up.save()
Ejemplo n.º 15
0
    def test_username_filled_in(self):
        """The username field should have a type and value."""
        newbie = user(username='******', country='pl', email='*****@*****.**')

        url = reverse('profile.edit')
        assert self.client.login(email=newbie.email)
        response = self.client.get(url, follow=True)

        eq_(200, response.status_code)
        doc = pq(response.content)
        field = doc('#id_username')[0]
        eq_('input', field.tag)
        assert 'value' in field.attrib
        eq_('text', field.attrib['type'])
        eq_(newbie.username, field.attrib['value'])
Ejemplo n.º 16
0
    def test_userprofile(self):
        u = user()

        UserProfile.objects.all().delete()

        # Somehow the User lacks a UserProfile
        # Note that u.get_profile() caches in memory.
        self.assertRaises(UserProfile.DoesNotExist, lambda: u.userprofile)

        # Sign in
        with browserid_mock.mock_browserid(u.email):
            d = dict(assertion="qwer")
            self.client.post(reverse("browserid_login"), d, follow=True)

        # Good to go
        assert u.get_profile()
Ejemplo n.º 17
0
    def test_userprofile(self):
        u = user()

        UserProfile.objects.all().delete()

        # Somehow the User lacks a UserProfile
        # Note that u.get_profile() caches in memory.
        self.assertRaises(UserProfile.DoesNotExist, lambda: u.userprofile)

        # Sign in
        with browserid_mock.mock_browserid(u.email):
            d = dict(assertion='qwer')
            self.client.post(reverse('browserid_verify'), d, follow=True)

        # Good to go
        assert u.get_profile()
Ejemplo n.º 18
0
    def setUp(self):
        """Setup API Testing."""
        # create an APP
        self.auto_user = user()
        up = self.auto_user.userprofile
        up.set_membership(Group, 'nice guy')
        up.set_membership(Skill, 'python')
        up.set_membership(Language, 'Greek')
        up.ircname = 'foobar'
        up.country = 'gr'
        up.region = 'Attika'
        up.city = 'Athens'
        up.full_name = 'Foo Bar'
        up.save()

        self.app = APIApp.objects.create(name='test_app',
                                         description='Foo',
                                         owner=self.mozillian,
                                         is_mozilla_app=False,
                                         is_active=False)

        index_all_profiles()
        get_es().flush(refresh=True)
Ejemplo n.º 19
0
 def test_not_index(self, mock_obj):
     """Test incomplete profiles indexing."""
     user()
     self.assertFalse(mock_obj.called, 'Incomplete profile get indexed')