Skip to content
Snippets Groups Projects
Commit bd057e8f authored by Mario Raciti's avatar Mario Raciti
Browse files

TMSS-692: Add custom ProjectQuota; add asserts

parent 14e13dc7
No related branches found
No related tags found
1 merge request!410Resolve TMSS-692
......@@ -511,6 +511,7 @@ class ProjectReportTest(unittest.TestCase):
def setUp(self):
# Create requirements
self.project = models.Project.objects.create(**Project_test_data(name='test_for_report'))
self.project_quota = models.ProjectQuota.objects.create(**ProjectQuota_test_data(project=self.project, resource_type=models.ResourceType.objects.create(**ResourceType_test_data(quantity=models.Quantity.objects.get(value=models.Quantity.Choices.NUMBER.value)))))
self.scheduling_set = models.SchedulingSet.objects.create(**SchedulingSet_test_data(project=self.project))
self.scheduling_unit_draft = models.SchedulingUnitDraft.objects.create(
**SchedulingUnitDraft_test_data(scheduling_set=self.scheduling_set))
......@@ -521,9 +522,11 @@ class ProjectReportTest(unittest.TestCase):
self.task_blueprint = models.TaskBlueprint.objects.create(
**TaskBlueprint_test_data(task_draft=self.task_draft, scheduling_unit_blueprint=self.scheduling_unit_blueprint))
def test_create_report(self):
# TODO: Add ProjectQuota sample.
# Create test_data_creator as superuser
self.test_data_creator = TMSSRESTTestDataCreator(BASE_URL, requests.auth.HTTPBasicAuth('test', 'test'))
response = requests.get(self.test_data_creator.django_api_url + '/', auth=self.test_data_creator.auth)
def test_create_report(self):
# Create Subtask of type 'ingest'
subtask_template = models.SubtaskTemplate.objects.create(**SubtaskTemplate_test_data(subtask_type_value='ingest'))
subtask = models.Subtask.objects.create(**Subtask_test_data(task_blueprint=self.task_blueprint, subtask_template=subtask_template))
......@@ -541,7 +544,18 @@ class ProjectReportTest(unittest.TestCase):
subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask))
dataproduct = models.Dataproduct.objects.create(**Dataproduct_test_data(producer=subtask_output))
# TODO: Assert we get the expected object.
# Assert we get the expected object
response = requests.get(BASE_URL + '/project/%s/report' % self.project.pk, auth=self.test_data_creator.auth)
result = response.json()
self.assertEqual(result['project'], self.project.name)
self.assertEqual(result['quota'][0]['id'], self.project_quota.pk)
# FIXME: Durations are stored as total_second(), find an alternative way.
# self.assertEqual(result['durations']['total'], subtask.duration) # There is only this subtask
self.assertEqual(result['durations']['scheduling_unit_blueprints_finished'][0]['id'], self.scheduling_unit_blueprint.pk)
self.assertEqual(result['durations']['scheduling_unit_blueprints_failed'], [])
self.assertEqual(result['LTA dataproducts']['size__sum'], dataproduct.size) # There is only this dataproduct
self.assertIsNotNone(result['SAPs']) # Just to check if the placeholder was added
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment