예제 #1
0
    def test_nonvouched_search(self):
        """Make sure that only non vouched users are returned on
        search.

        """
        amanda = 'Amanda Younger'
        amandeep = 'Amandeep McIlrath'

        user(first_name='Amanda', last_name='Unvouched')

        url = reverse('search')
        r = self.mozillian_client.get(url, {'q': 'Am'})
        rnv = self.mozillian_client.get(url, {'q': 'Am', 'nonvouched_only': 1})

        eq_(r.status_code, 200)
        peeps = r.context['people']
        peeps_nv = rnv.context['people']

        saw_amanda = saw_amandeep = False

        for person in peeps:
            if person.display_name == amandeep:
                assert person.is_vouched, 'Amanda is a Mozillian'
                saw_amandeep = True
            elif person.display_name == amanda:
                if person.is_vouched:
                    self.fail('Amandeep should have pending status')
                saw_amanda = True
            if saw_amanda and saw_amandeep:
                break

        assert amanda in [p.display_name for p in peeps_nv]
        self.assertTrue(saw_amanda, 'We see vouched users')
        self.assertTrue(saw_amandeep, 'We see non-vouched users')
        assert all(not person.is_vouched for person in peeps_nv)
예제 #2
0
    def test_nonvouched_search(self):
        """Make sure that only non vouched users are returned on search."""
        amanda = "Amanda Younger"
        amandeep = "Amandeep McIlrath"

        user(first_name="Amanda", last_name="Unvouched")

        url = reverse("search")
        r = self.mozillian_client.get(url, {"q": "Am"})
        rnv = self.mozillian_client.get(url, {"q": "Am", "nonvouched_only": 1})

        eq_(r.status_code, 200)
        peeps = r.context["people"]
        peeps_nv = rnv.context["people"]

        saw_amanda = saw_amandeep = False

        for person in peeps:
            if person.display_name == amandeep:
                assert person.is_vouched, "Amanda is a Mozillian"
                saw_amandeep = True
            elif person.display_name == amanda:
                if person.is_vouched:
                    self.fail("Amandeep should have pending status")
                saw_amanda = True
            if saw_amanda and saw_amandeep:
                break

        assert amanda in [p.display_name for p in peeps_nv]
        self.assertTrue(saw_amanda, "We see vouched users")
        self.assertTrue(saw_amandeep, "We see non-vouched users")
        assert all(not person.is_vouched for person in peeps_nv)
예제 #3
0
    def test_nonvouched_search(self):
        """Make sure that only non vouched users are returned on
        search.

        """
        amanda = 'Amanda Younger'
        amandeep = 'Amandeep McIlrath'

        user(first_name='Amanda', last_name='Unvouched')

        url = reverse('search')
        r = self.mozillian_client.get(url, {'q': 'Am'})
        rnv = self.mozillian_client.get(url, {'q': 'Am', 'nonvouched_only': 1})

        eq_(r.status_code, 200)
        peeps = r.context['people']
        peeps_nv = rnv.context['people']

        saw_amanda = saw_amandeep = False

        for person in peeps:
            if person.display_name == amandeep:
                assert person.is_vouched, 'Amanda is a Mozillian'
                saw_amandeep = True
            elif person.display_name == amanda:
                if person.is_vouched:
                    self.fail('Amandeep should have pending status')
                saw_amanda = True
            if saw_amanda and saw_amandeep:
                break

        assert amanda in [p.display_name for p in peeps_nv]
        self.assertTrue(saw_amanda, 'We see vouched users')
        self.assertTrue(saw_amandeep, 'We see non-vouched users')
        assert all(not person.is_vouched for person in peeps_nv)
예제 #4
0
    def test_proper_url_arg_handling(self):
        """Make sure URL arguments are handled correctly"""
        # Create a new unvouched user to ensure results show up in search view
        user()

        search_url = reverse("search")
        r = self.mozillian_client.get(search_url)
        assert not pq(r.content)(".result")

        r = self.mozillian_client.get(search_url, {"q": u"", "nonvouched_only": 1})

        assert pq(r.content)(".result")
예제 #5
0
    def test_proper_url_arg_handling(self):
        """Make sure URL arguments are handled correctly."""
        # Create a new unvouched user to ensure results show up in search view
        user()

        search_url = reverse('search')
        r = self.mozillian_client.get(search_url)
        assert not pq(r.content)('.result')

        r = self.mozillian_client.get(search_url,
                                      {'q': u'', 'nonvouched_only': 1})

        assert pq(r.content)('.result')
예제 #6
0
    def test_proper_url_arg_handling(self):
        """Make sure URL arguments are handled correctly"""
        # Create a new unvouched user to ensure results show up in search view
        user()

        search_url = reverse('search')
        r = self.mozillian_client.get(search_url)
        assert not pq(r.content)('.result')

        r = self.mozillian_client.get(search_url,
                                      {'q': u'', 'nonvouched_only': 1})

        assert pq(r.content)('.result')
예제 #7
0
    def test_profilepic_search(self):
        """Make sure searching for only users with profile pics works."""

        user(first_name="Aman", vouched=True, photo=True)
        user(first_name="Amanda", vouched=True, photo=True)
        u = user(first_name="Amihuman", vouched=True)

        self.client.login(email=u.email)

        url = reverse("search")

        r_pics_only = self.client.get(url, {"q": "Am", "picture_only": 1})
        eq_(r_pics_only.status_code, 200)
        pics_only_peeps = r_pics_only.context["people"]
        for person in pics_only_peeps:
            assert person.photo, "Every person should have a photo"

        r = self.client.get(url, {"q": "Am"})
        eq_(r.status_code, 200)
        peeps = r.context["people"]
        # Make sure u shows up in normal search
        assert u in [p.user for p in peeps]
        # Make sure u doesn't show up in picture only search
        assert u not in [p.user for p in pics_only_peeps]
예제 #8
0
    def test_single_result(self):
        """Makes sure the client is redirected to the users page
        if they are the only result returned by the query.
        """
        u = user(first_name="Findme", last_name="Ifyoucan")

        r = create_client(vouched=True).get(reverse("search"), {"q": "Fin", "nonvouched_only": 1}, follow=True)

        eq_(r.status_code, 200, "Search view query should return 200")

        eq_(
            u.get_profile().display_name,
            pq(r.content)("#profile-info h2").text(),
            "Should be redirected to a user with the right name",
        )
예제 #9
0
    def test_profilepic_search(self):
        """Make sure searching for only users with profile pics works."""

        user(first_name='Aman', vouched=True, photo=True)
        user(first_name='Amanda', vouched=True, photo=True)
        u = user(first_name='Amihuman', vouched=True)

        self.client.login(email=u.email)

        url = reverse('search')

        r_pics_only = self.client.get(url, {'q': 'Am', 'picture_only': 1})
        eq_(r_pics_only.status_code, 200)
        pics_only_peeps = r_pics_only.context['people']
        for person in pics_only_peeps:
            assert person.photo, 'Every person should have a photo'

        r = self.client.get(url, {'q': 'Am'})
        eq_(r.status_code, 200)
        peeps = r.context['people']
        # Make sure u shows up in normal search
        assert u in [p.user for p in peeps]
        # Make sure u doesn't show up in picture only search
        assert u not in [p.user for p in pics_only_peeps]
예제 #10
0
    def test_profilepic_search(self):
        """Make sure searching for only users with profile pics works."""

        user(first_name='Aman', vouched=True, photo=True)
        user(first_name='Amanda', vouched=True, photo=True)
        u = user(first_name='Amihuman', vouched=True)

        self.client.login(email=u.email)

        url = reverse('search')

        r_pics_only = self.client.get(url, {'q': 'Am', 'picture_only': 1})
        eq_(r_pics_only.status_code, 200)
        pics_only_peeps = r_pics_only.context['people']
        for person in pics_only_peeps:
            assert person.photo, 'Every person should have a photo'

        r = self.client.get(url, {'q': 'Am'})
        eq_(r.status_code, 200)
        peeps = r.context['people']
        # Make sure u shows up in normal search
        assert u in [p.user for p in peeps]
        # Make sure u doesn't show up in picture only search
        assert u not in [p.user for p in pics_only_peeps]
예제 #11
0
    def test_single_result(self):
        """Makes sure the client is redirected to the users page
        if they are the only result returned by the query.
        """
        u = user(first_name='Findme', last_name='Ifyoucan')

        r = create_client(vouched=True).get(reverse('search'),
                                            {'q': 'Fin', 'nonvouched_only': 1},
                                                 follow=True)

        eq_(r.status_code, 200, 'Search view query should return 200')

        eq_(u.get_profile().display_name,
            pq(r.content)('#profile-info h2').text(),
            'Should be redirected to a user with the right name')
예제 #12
0
    def test_single_result(self):
        """Makes sure the client is redirected to the users page
        if they are the only result returned by the query.
        """
        u = user(first_name='Findme', last_name='Ifyoucan')

        r = create_client(vouched=True).get(reverse('search'),
                                            {'q': 'Fin', 'nonvouched_only': 1},
                                                 follow=True)

        eq_(r.status_code, 200, 'Search view query should return 200')

        eq_(u.get_profile().display_name,
            pq(r.content)('#profile-info h2').text(),
            'Should be redirected to a user with the right name')