def test_no_contest(self): unregister_main_page_view(szkopul_main_page) with self.assertNumQueriesLessThan(50): response = self.client.get('/') self.assertContains(response, 'There are no contests available to logged out') with self.assertNumQueriesLessThan(50): self.assertTrue(self.client.login(username='******')) response = self.client.get('/') self.assertContains(response, 'This is a new OIOIOI installation') @register_main_page_view(order=100) def set_main_page_back(request): return szkopul_main_page(request)
def test_no_contest(self): unregister_main_page_view(szkopul_main_page) with self.assertNumQueriesLessThan(50): response = self.client.get('/') self.assertContains( response, 'There are no contests available to logged out') with self.assertNumQueriesLessThan(50): self.assertTrue(self.client.login(username='******')) response = self.client.get('/') self.assertContains(response, 'This is a new OIOIOI installation') @register_main_page_view(order=100) def set_main_page_back(request): return szkopul_main_page(request)
def test_custom_main_page(self): @register_main_page_view(order=0, condition=Condition(lambda request: False)) def inaccessible(request): pass @register_main_page_view(order=1) def accessible(request): return TemplateResponse(request, 'index.html') response = self.client.get('/') self.assertIn('This is a test index template', response.content) unregister_main_page_view(inaccessible) unregister_main_page_view(accessible)
def test_custom_main_page(self): @register_main_page_view(order=0, condition=Condition(lambda request: False)) def inaccessible(request): pass @register_main_page_view(order=1) def accessible(request): return TemplateResponse(request, 'index.html') response = self.client.get('/') self.assertIn('This is a test index template', response.content) unregister_main_page_view(inaccessible) unregister_main_page_view(accessible)
def test_custom_main_page(self): @register_main_page_view(order=0, condition=Condition(lambda request: False)) def inaccessible(request): pass @register_main_page_view(order=1) def accessible(request): return TemplateResponse(request, 'index.html') try: response = self.client.get('/') self.assertIn('This is a test index template', response.content) finally: # Perform cleanup regardless of the test failure/success unregister_main_page_view(inaccessible) unregister_main_page_view(accessible)
def test_custom_main_page(self): @register_main_page_view(order=0, condition=Condition(lambda request: False)) def inaccessible(request): pass @register_main_page_view(order=1) def accessible(request): return TemplateResponse(request, 'index.html') try: response = self.client.get('/') self.assertContains(response, 'This is a test index template') finally: # Perform cleanup regardless of the test failure/success unregister_main_page_view(inaccessible) unregister_main_page_view(accessible)