def test_breadcrumb(): """Make sure breadcrumb links start with /.""" c = LocalizingClient() response = c.get(reverse('search')) doc = pq(response.content) href = doc('.breadcrumbs a')[0] eq_('/', href.attrib['href'][0])
def test_breadcrumb(): """Make sure breadcrumb links start with /.""" c = LocalizingClient() response = c.get(reverse("search")) doc = pq(response.content) href = doc(".breadcrumbs a")[0] eq_("/", href.attrib["href"][0])
def es_search_cmd(query, pages=1, log=log): """Simulates a front page search .. Note:: This **doesn't** simulate an advanced search---just a front page search. """ from kitsune.sumo.tests import LocalizingClient from kitsune.sumo.urlresolvers import reverse client = LocalizingClient() output = [] output.append('Search for: %s' % query) output.append('') data = { 'q': query, 'format': 'json' } url = reverse('search') # The search view shows 10 results at a time. So we hit it few # times---once for each page. for pageno in range(pages): pageno = pageno + 1 data['page'] = pageno resp = client.get(url, data) if resp.status_code != 200: output.append('ERROR: %s' % resp.content) break else: content = json.loads(resp.content) results = content[u'results'] for mem in results: output.append(u'%4d %5.2f %-10s %-20s' % ( mem['rank'], mem['score'], mem['type'], mem['title'])) output.append('') for line in output: log.info(line.encode('ascii', 'ignore'))
def es_search_cmd(query, pages=1, log=log): """Simulates a front page search .. Note:: This **doesn't** simulate an advanced search---just a front page search. """ from kitsune.sumo.tests import LocalizingClient from kitsune.sumo.urlresolvers import reverse client = LocalizingClient() output = [] output.append("Search for: %s" % query) output.append("") data = {"q": query, "format": "json"} url = reverse("search") # The search view shows 10 results at a time. So we hit it few # times---once for each page. for pageno in range(pages): pageno = pageno + 1 data["page"] = pageno resp = client.get(url, data) if resp.status_code != 200: output.append("ERROR: %s" % resp.content) break else: content = json.loads(resp.content) results = content["results"] for mem in results: output.append( "%4d %5.2f %-10s %-20s" % (mem["rank"], mem["score"], mem["type"], mem["title"])) output.append("") for line in output: log.info(line.encode("ascii", "ignore"))
class AwardsListTests(TestCase): client = LocalizingClient() def test_list_empty(self): resp = self.client.get(reverse('kbadge.awards_list'), follow=True) eq_(200, resp.status_code) def test_list_with_awards(self): b = BadgeFactory() a1 = AwardFactory(description=u'A1 AWARD', badge=b) a2 = AwardFactory(description=u'A2 AWARD', badge=b) a3 = AwardFactory(description=u'A3 AWARD', badge=b) resp = self.client.get(reverse('kbadge.awards_list'), follow=True) eq_(200, resp.status_code) self.assertContains(resp, a1.user.username) self.assertContains(resp, a1.get_absolute_url()) self.assertContains(resp, a2.user.username) self.assertContains(resp, a2.get_absolute_url()) self.assertContains(resp, a3.user.username) self.assertContains(resp, a3.get_absolute_url())
class AwardsListTests(TestCase): client = LocalizingClient() def test_list_empty(self): resp = self.client.get(reverse('badger.awards_list'), follow=True) eq_(200, resp.status_code) def test_list_with_awards(self): b = badge(save=True) a1 = award(description=u'A1 AWARD', badge=b, save=True) a2 = award(description=u'A2 AWARD', badge=b, save=True) a3 = award(description=u'A3 AWARD', badge=b, save=True) resp = self.client.get(reverse('badger.awards_list'), follow=True) eq_(200, resp.status_code) self.assertContains(resp, a1.description) self.assertContains(resp, a1.get_absolute_url()) self.assertContains(resp, a2.description) self.assertContains(resp, a2.get_absolute_url()) self.assertContains(resp, a3.description) self.assertContains(resp, a3.get_absolute_url())