def setUp(self): self.report1 = Report.objects.get(pk=1) self.revision1 = Revision.objects.get(pk=1) self.executable1 = Executable.objects.get(pk=1) self.environment1 = Environment.objects.get(pk=1) self.executable2_data = dict( name="Fibo", description="Fibonacci the Lame", ) self.project = Project.objects.get(pk=1) self.executable2 = Executable(project=self.project, **self.executable2_data) self.executable2.save() self.report2_data = dict( revision=self.revision1, environment=self.environment1, executable=self.executable2, ) self.report2 = Report(**self.report2_data) self.report2.save() self.report2_data = dict( revision='/api/v1/revision/{0}/'.format(self.revision1.id), environment='/api/v1/environment/{0}/'.format( self.environment1.id), executable='/api/v1/executable/{0}/'.format(self.executable2.id), ) self.client = Client() super(ReportTest, self).setUp()
def setUp(self): self.report1 = Report.objects.get(pk=1) self.revision1 = Revision.objects.get(pk=1) self.executable1 = Executable.objects.get(pk=1) self.environment1 = Environment.objects.get(pk=1) self.executable2_data = dict( name="Fibo", description="Fibonacci the Lame", ) self.project=Project.objects.get(pk=1) self.executable2 = Executable(project=self.project, **self.executable2_data) self.executable2.save() self.report2_data = dict( revision=self.revision1, environment=self.environment1, executable=self.executable2, ) self.report2 = Report(**self.report2_data) self.report2.save() self.report2_data = dict( revision='/api/v1/revision/{0}/'.format(self.revision1.id), environment='/api/v1/environment/{0}/'.format(self.environment1.id), executable='/api/v1/executable/{0}/'.format(self.executable2.id), ) self.client = Client() super(ReportTest, self).setUp()
def result_filter(self): return Report.significant_default_filter()
def result_filter(self): return Report.default_filter()
class ReportTest(FixtureTestCase): """Test Report() API""" def setUp(self): self.report1 = Report.objects.get(pk=1) self.revision1 = Revision.objects.get(pk=1) self.executable1 = Executable.objects.get(pk=1) self.environment1 = Environment.objects.get(pk=1) self.executable2_data = dict( name="Fibo", description="Fibonacci the Lame", ) self.project = Project.objects.get(pk=1) self.executable2 = Executable(project=self.project, **self.executable2_data) self.executable2.save() self.report2_data = dict( revision=self.revision1, environment=self.environment1, executable=self.executable2, ) self.report2 = Report(**self.report2_data) self.report2.save() self.report2_data = dict( revision='/api/v1/revision/{0}/'.format(self.revision1.id), environment='/api/v1/environment/{0}/'.format( self.environment1.id), executable='/api/v1/executable/{0}/'.format(self.executable2.id), ) self.client = Client() super(ReportTest, self).setUp() def test_get_report(self): """Should get an existing report""" response = self.client.get('/api/v1/report/1/') self.assertEquals(response.status_code, 200) self.assertEqual( json.loads(response.content)['summary'], 'float -50.0%') self.assertEqual(json.loads(response.content)['colorcode'], "green") def test_get_report_all_fields(self): """Should get all fields for an report""" response = self.client.get('/api/v1/report/{0}/'.format( self.report2.id, )) self.assertEquals(response.status_code, 200) for k, v in self.report2_data.items(): self.assertEqual(json.loads(response.content)[k], v) def test_post(self): """Should save a new report""" modified_data = copy.deepcopy(self.report2_data) response = self.client.post('/api/v1/report/', data=json.dumps(modified_data), content_type='application/json') # next has to be 405, otherwise would raise IntegrityError self.assertEquals(response.status_code, 405) def test_put(self): """Should modify an existing report""" modified_data = copy.deepcopy(self.report2_data) response = self.client.put('/api/v1/report/1/', data=json.dumps(modified_data), content_type='application/json') self.assertEquals(response.status_code, 405) def test_delete(self): """Should delete a report""" response = self.client.get('/api/v1/report/1/') self.assertEquals(response.status_code, 200) # from fixture response = self.client.delete('/api/v1/report/1/', content_type='application/json') self.assertEquals(response.status_code, 405)
def make_report(self, revision): Report(revision=revision, environment=self.env, executable=self.exe).save() return Report.objects.get(revision=revision)
class ReportTest(FixtureTestCase): """Test Report() API""" def setUp(self): self.report1 = Report.objects.get(pk=1) self.revision1 = Revision.objects.get(pk=1) self.executable1 = Executable.objects.get(pk=1) self.environment1 = Environment.objects.get(pk=1) self.executable2_data = dict( name="Fibo", description="Fibonacci the Lame", ) self.project=Project.objects.get(pk=1) self.executable2 = Executable(project=self.project, **self.executable2_data) self.executable2.save() self.report2_data = dict( revision=self.revision1, environment=self.environment1, executable=self.executable2, ) self.report2 = Report(**self.report2_data) self.report2.save() self.report2_data = dict( revision='/api/v1/revision/{0}/'.format(self.revision1.id), environment='/api/v1/environment/{0}/'.format(self.environment1.id), executable='/api/v1/executable/{0}/'.format(self.executable2.id), ) self.client = Client() super(ReportTest, self).setUp() def test_get_report(self): """Should get an existing report""" response = self.client.get('/api/v1/report/1/') self.assertEquals(response.status_code, 200) self.assertEqual(json.loads(response.content)['summary'], 'float -50.0%') self.assertEqual(json.loads(response.content)['colorcode'], "green") def test_get_report_all_fields(self): """Should get all fields for an report""" response = self.client.get('/api/v1/report/{0}/'.format( self.report2.id,)) self.assertEquals(response.status_code, 200) for k, v in self.report2_data.items(): self.assertEqual(json.loads(response.content)[k], v) def test_post(self): """Should save a new report""" modified_data = copy.deepcopy(self.report2_data) response = self.client.post('/api/v1/report/', data=json.dumps(modified_data), content_type='application/json') # next has to be 405, otherwise would raise IntegrityError self.assertEquals(response.status_code, 405) def test_put(self): """Should modify an existing report""" modified_data = copy.deepcopy(self.report2_data) response = self.client.put('/api/v1/report/1/', data=json.dumps(modified_data), content_type='application/json') self.assertEquals(response.status_code, 405) def test_delete(self): """Should delete a report""" response = self.client.get('/api/v1/report/1/') self.assertEquals(response.status_code, 200) # from fixture response = self.client.delete('/api/v1/report/1/', content_type='application/json') self.assertEquals(response.status_code, 405)