def test_template_delete(self): template = ReportTemplate( name="test2", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "johndoe"}, description="Some", graph=self.graph, ) template.save() template_id = template.id try: t = ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertTrue(exists) t.delete() try: ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertFalse(exists)
class ReportTemplateTest(TestCase): fixtures = ["schemas.json", "graphs.json", "queries.json", "reports.json"] def setUp(self): self.query1 = Query.objects.get(pk=1) self.query2 = Query.objects.get(pk=2) self.graph = Graph.objects.get(pk=1) self.template = ReportTemplate(name="test", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "world"}, description="Some", graph=self.graph) self.template.save() self.template.queries.add(self.query1) self.template.queries.add(self.query2) self.template_id = self.template.id def test_template_creation(self): self.assertIsNotNone(self.template) self.assertEqual(self.template.name, "test") def test_template_update(self): template = ReportTemplate.objects.get(pk=self.template_id) template.name = "test this yo!" template.save() self.assertEqual(template.name, "test this yo!") def test_report_delete(self): template = ReportTemplate(name="test2", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "johndoe"}, description="Some", graph=self.graph) template.save() template_id = template.id try: t = ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertTrue(exists) t.delete() try: ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertFalse(exists)
def test_delete_endpoint_del(self): template = ReportTemplate(name="endpointdelete", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "johndoe"}, description="Some", graph=self.graph) template.save() template_id = template.id t = ReportTemplate.objects.get(pk=template_id) self.assertIsNotNone(t) url = reverse('delete', kwargs={"graph_slug": "dh2014"}) resp = self.client.post(url, json.dumps({"template": template.slug}), content_type="application/json") self.assertEqual(resp.status_code, 200) try: ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertEqual(exists, False)
class ReportTest(TestCase): fixtures = ["schemas.json", "graphs.json", "queries.json", "reports.json"] def setUp(self): self.graph = Graph.objects.get(pk=1) self.template = ReportTemplate(name="test", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "world"}, description="Some", graph=self.graph) self.template.save() self.template_id = self.template.id self.datetime = datetime.now() self.report = Report(date_run=self.datetime, table={"hello": "again"}, template=self.template) self.report.save() def test_report_creation(self): self.assertIsNotNone(self.report) self.assertEqual(self.report.date_run, self.datetime) def test_report_delete(self): report = Report(date_run=datetime.now(), table={"hello": "again"}, template=self.template) report.save() rid = report.id try: r = Report.objects.get(pk=rid) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertTrue(exists) r.delete() try: Report.objects.get(pk=rid) exists = True except Report.DoesNotExist: exists = False self.assertFalse(exists)
class ReportTest(TestCase): fixtures = ["schemas.json", "graphs.json", "queries.json", "reports.json"] def setUp(self): self.graph = Graph.objects.get(pk=1) self.template = ReportTemplate( name="test", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "world"}, description="Some", graph=self.graph, ) self.template.save() self.template_id = self.template.id self.datetime = datetime.now() self.report = Report(date_run=self.datetime, table={"hello": "again"}, template=self.template) self.report.save() def test_report_creation(self): self.assertIsNotNone(self.report) self.assertEqual(self.report.date_run, self.datetime) def test_report_delete(self): report = Report(date_run=datetime.now(), table={"hello": "again"}, template=self.template) report.save() rid = report.id try: r = Report.objects.get(pk=rid) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertTrue(exists) r.delete() try: Report.objects.get(pk=rid) exists = True except Report.DoesNotExist: exists = False self.assertFalse(exists)
def test_template_delete(self): template = ReportTemplate(name="test2", start_date=datetime.now(), frequency="h", last_run=datetime.now(), layout={"hello": "johndoe"}, description="Some", graph=self.graph) template.save() template_id = template.id try: t = ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertTrue(exists) t.delete() try: ReportTemplate.objects.get(pk=template_id) exists = True except ReportTemplate.DoesNotExist: exists = False self.assertFalse(exists)