def test_update_test(self): test = factories.TestFactory() self.assertNotEqual("updated", test.name) request = self.client.put("/api/tests/%s" % test.id, {"name": "updated"}) self.assertEqual(200, request.status_code) test_updated = models.Test.objects.get(id=test.id) self.assertEqual("updated", test_updated.name)
def test_create_rfe(self): product = factories.ProductFactory() test1 = factories.TestFactory(name="test id 1") test2 = factories.TestFactory(name="test id 2") self.assertEqual(0, models.RFE.objects.count()) data = { "name": "p1", "url": "https://example.org/rfes/1", "product": product.id, "tests": [test1.id, test2.id], } request = self.client.post( "/api/rfes", data, ) self.assertEqual(201, request.status_code) self.assertEqual(1, models.RFE.objects.count()) for key in data: self.assertIn(key, request.data) self.assertEqual(data[key], request.data[key])
def test_upload(self): xmlfile = open( os.path.join(os.path.dirname(__file__), "tempest-results-full.1.xml")) product = factories.ProductFactory() test = factories.TestFactory( name= "tempest.api.compute.admin.test_simple_tenant_usage_negative.TenantUsagesNegativeTestJSON.test_get_usage_tenant_with_empty_tenant_id" ) rfe = factories.RFEFactory(product=product, tests=[test]) response = self.client.post( "/api/upload", { "product": product.id, "url": "https://example.org/jobs/1", "build": "2018-06-20.1", "file": xmlfile, "result": "SUCCESS", }, format="multipart", ) self.assertEqual(201, response.status_code) test = models.Test.objects.get( name= "tempest.api.compute.admin.test_simple_tenant_usage_negative.TenantUsagesNegativeTestJSON.test_get_usage_tenant_with_empty_tenant_id" ) job_result = models.JobResult.objects.get( build="2018-06-20.1", url="https://example.org/jobs/1", product=product.id) self.assertEquals(job_result.jobname, "jobs") test_result = models.TestResult.objects.get(test=test, job_result=job_result) self.assertTrue(test_result.result) rfe_result = models.RFEResult.objects.get(rfe=rfe) self.assertTrue(rfe_result.result) self.assertEquals(rfe_result.percent, 100.00)
def test_upload(self): product = factories.ProductFactory() test = factories.TestFactory(name=TEST_NAME) rfe = factories.RFEFactory(product=product, tests=[test]) test = models.Test.objects.get(name=TEST_NAME) self.upload_file(product, "tempest-results-full.1.xml") job_result = models.JobResult.objects.get( build="2018-06-20.1", url="https://example.org/jobs/1", product=product.id) self.assertEquals(job_result.jobname, "jobs") test_result = models.TestResult.objects.get(test=test, job_result=job_result) self.assertTrue(test_result.result) rfe_result = models.RFEResult.objects.get(rfe=rfe) self.assertTrue(rfe_result.result) self.assertEquals(rfe_result.percent, 100.00) nb = models.TestResult.objects.filter(job_result=job_result).count() # change in tempest-results-full.2.xml is one test is failing self.upload_file(product, "tempest-results-full.2.xml") nb_job_result = models.JobResult.objects.all().count() self.assertEquals(nb_job_result, 1) nb2 = models.TestResult.objects.filter(job_result=job_result).count() self.assertEquals(nb, nb2)
def test_test_factory(self): test = factories.TestFactory(name="factory") self.assertEqual(test.name, "factory")
def test_delete_test(self): test = factories.TestFactory() self.assertEqual(1, models.Test.objects.all().count()) request = self.client.delete("/api/tests/%s" % test.id) self.assertEqual(204, request.status_code) self.assertEqual(0, models.Test.objects.all().count())
def test_get_test(self): test = factories.TestFactory() request = self.client.get("/api/tests/%s" % test.id) self.assertEqual(test.name, request.data["name"])
def test_get_tests(self): test = factories.TestFactory() request = self.client.get("/api/tests") self.assertEqual(1, len(request.data)) self.assertEqual(test.name, request.data[0]["name"])