def test_post_valid(self): self.request.method = 'POST' self.request.POST = self.querydict G(SimpleDemoModel, char='abc', integer1=10) response = ReportFilter.as_view()(self.request, pk=self.config.pk) self.assertIn('ereports.engine.report.BaseReport', str(response)) self.assertIn('Integer #1', str(response))
def test_post_valid_no_ds(self): self.request.method = 'POST' self.request.POST = self.querydict #TODO catch message error value and confirm with patch('ereports.views.messages'): response = ReportFilter.as_view()(self.request, pk=self.config.pk) self.assertIn('query', response.context_data)
def test_get(self): response = ReportFilter.as_view()(self.request, pk=self.config.pk) self.assertIn('configuration', response.context_data) self.assertIn('today', response.context_data) self.assertEqual(response.context_data['today'].strftime("%Y-%m-%d"), datetime.datetime.today().strftime("%Y-%m-%d")) self.assertIn('user', response.context_data) self.assertEqual(response.context_data['user'], self.request.user)
def test_post_invalid(self): self.request.method = 'POST' #TODO catch message error value and confirm with patch('ereports.views.messages'): response = ReportFilter.as_view()(self.request, pk=self.config.pk) self.assertIn('form', response.context_data)