def test_index_listings(self): expected_htmls = ['testhtml', 'otherone'] self.mox.StubOutWithMock(services.listing_service, 'index_tags') services.listing_service.index_tags().AndReturn(TEST_TAGLIST) self.mox.StubOutWithMock(services.listing_service, 'collect_index_dict') services.listing_service.collect_index_dict( TEST_TAGLIST, home_only=True ).AndReturn(TEST_INDEX_CATEGORIES) self.mox.StubOutWithMock(public_controller, 'render_html_category') public_controller.render_html_category( mox.IsA(str), 'altcategory', ['altsubcat1', 'altsubcat2', 'altsubcat3'] ).InAnyOrder().AndReturn('testhmtl') public_controller.render_html_category( mox.IsA(str), 'category', ['subcat2', 'subcat3'] ).InAnyOrder().AndReturn('otherone') self.mox.ReplayAll() result = self.app.get('/') self.assertEqual(200, result.status_code) self.assertTrue('testhmtl' in result.data) self.assertTrue('otherone' in result.data)
def test_render_html_category(self): test_base_url = 'test_base_url.com' test_category = 'category' test_subcategories = ['altsubcat1', 'altsubcat2', 'altsubcat3'] with self.orig_app.test_request_context('/'): result = public_controller.render_html_category( test_base_url, test_category, test_subcategories ) self.assertTrue('href="test_base_url.com/category"' in result) self.assertTrue( 'href="test_base_url.com/category/altsubcat1"' in result) self.assertTrue( 'href="test_base_url.com/category/altsubcat2"' in result) self.assertTrue( 'href="test_base_url.com/category/altsubcat3"' in result)