Skip to content
Snippets Groups Projects
Commit c82bfaae authored by Nico Vermaas's avatar Nico Vermaas
Browse files

handle review comments

parent 96cb5284
Branches
Tags
1 merge request!361SDC-1423 use aggregation strategy
Pipeline #88768 passed
...@@ -123,8 +123,8 @@ def update_finished_fraction(task): ...@@ -123,8 +123,8 @@ def update_finished_fraction(task):
def reset_activity(task): def reset_activity(task):
""" """
The IngestQ page shows the fraction of completed/archived tasks per SAS_ID When a task is recycled back to DEFINED or FETCHED then the activity as a whole is no longer 'processed' or 'aggregated'.
This is the function that calculates that fraction when a relevant status transition was done. Reset those fields accordingly
""" """
try: try:
logger.info(f'- reset activity') logger.info(f'- reset activity')
...@@ -170,7 +170,7 @@ def update_processed_and_aggregate(task): ...@@ -170,7 +170,7 @@ def update_processed_and_aggregate(task):
activity.save() activity.save()
def update_verified(task): def update_is_verified(task):
""" """
The Validation page shows Activities (SAS_ID's) that are ready to be validated, by giving them a quality. The Validation page shows Activities (SAS_ID's) that are ready to be validated, by giving them a quality.
All tasks belonging to the SAS_ID must be 'verified' for that. All tasks belonging to the SAS_ID must be 'verified' for that.
...@@ -253,7 +253,7 @@ def update_activity(task): ...@@ -253,7 +253,7 @@ def update_activity(task):
update_processed_and_aggregate(task) update_processed_and_aggregate(task)
# check if all tasks for this activity are in a verified status. # check if all tasks for this activity are in a verified status.
update_verified(task) update_is_verified(task)
# check if users have changed certain fields after the specification step # check if users have changed certain fields after the specification step
update_changed_fields(task) update_changed_fields(task)
...@@ -55,7 +55,7 @@ class TestProcessedSummary(TestCase): ...@@ -55,7 +55,7 @@ class TestProcessedSummary(TestCase):
def test_processed_not_on_hold_for_different_strategy(self): def test_processed_not_on_hold_for_different_strategy(self):
""" """
# this is a summary task, but it uses a workflow with an aggregation_strategy that should not hold the task this is a summary task, but it uses a workflow with an aggregation_strategy that should not hold the task
""" """
actual = self.task4.resume actual = self.task4.resume
self.assertEqual(actual, True) self.assertEqual(actual, True)
......
...@@ -90,8 +90,7 @@ class TestUpdateActivity(TestCase): ...@@ -90,8 +90,7 @@ class TestUpdateActivity(TestCase):
activity = self.task1.activity activity = self.task1.activity
# test if an activity with the correct sas_id was created # test if an activity with the correct sas_id was created
actual = activity.sas_id self.assertEqual(activity.sas_id, 12345)
self.assertEqual(actual, 12345)
def test_scrubbed(self): def test_scrubbed(self):
...@@ -100,11 +99,8 @@ class TestUpdateActivity(TestCase): ...@@ -100,11 +99,8 @@ class TestUpdateActivity(TestCase):
""" """
activity = self.task2.activity activity = self.task2.activity
actual = activity.ingestq_status self.assertEqual(activity.ingestq_status, {'scrubbed': 1})
self.assertEqual(actual, {'scrubbed': 1}) self.assertEqual(activity.ingested_fraction, 0)
actual = activity.ingested_fraction
self.assertEqual(actual, 0)
def test_archived(self): def test_archived(self):
...@@ -113,11 +109,8 @@ class TestUpdateActivity(TestCase): ...@@ -113,11 +109,8 @@ class TestUpdateActivity(TestCase):
""" """
activity = self.task3.activity activity = self.task3.activity
actual = activity.ingestq_status self.assertEqual(activity.ingestq_status, {'scrubbed': 1, 'archived': 1})
self.assertEqual(actual, {'scrubbed': 1, 'archived': 1}) self.assertEqual(activity.archive['sas_id_archived'], "1219995")
actual = activity.archive['sas_id_archived']
self.assertEqual(actual, "1219995")
def test_finished(self): def test_finished(self):
...@@ -127,11 +120,8 @@ class TestUpdateActivity(TestCase): ...@@ -127,11 +120,8 @@ class TestUpdateActivity(TestCase):
activity = self.task4.activity activity = self.task4.activity
actual = activity.ingestq_status self.assertEqual(activity.ingestq_status, {'scrubbed': 1, 'finished': 1, 'archived': 1})
self.assertEqual(actual, {'scrubbed': 1, 'finished': 1, 'archived': 1}) self.assertEqual(activity.archive['sas_id_archived'], "1219995")
actual = activity.archive['sas_id_archived']
self.assertEqual(actual, "1219995")
def test_failed(self): def test_failed(self):
...@@ -141,14 +131,9 @@ class TestUpdateActivity(TestCase): ...@@ -141,14 +131,9 @@ class TestUpdateActivity(TestCase):
activity = self.task5.activity activity = self.task5.activity
actual = activity.finished_fraction self.assertEqual(activity.finished_fraction, 33)
self.assertEqual(actual, 33) self.assertEqual(activity.total_size, 3000)
self.assertEqual(activity.remaining, 2000)
actual = activity.total_size
self.assertEqual(actual, 3000)
actual = activity.remaining
self.assertEqual(actual, 2000)
def test_filter_and_workflow(self): def test_filter_and_workflow(self):
...@@ -157,12 +142,8 @@ class TestUpdateActivity(TestCase): ...@@ -157,12 +142,8 @@ class TestUpdateActivity(TestCase):
""" """
activity = self.task1.activity activity = self.task1.activity
self.assertEqual(activity.filter, "test_blabla")
actual = activity.filter self.assertEqual(activity.workflow_id, 22)
self.assertEqual(actual, "test_blabla")
actual = activity.workflow_id
self.assertEqual(actual, 22)
def test_is_not_processed(self): def test_is_not_processed(self):
""" """
...@@ -171,9 +152,7 @@ class TestUpdateActivity(TestCase): ...@@ -171,9 +152,7 @@ class TestUpdateActivity(TestCase):
""" """
activity = self.task9.activity activity = self.task9.activity
self.assertFalse(activity.is_processed)
actual = activity.is_processed
self.assertEqual(actual, False)
def test_is_processed(self): def test_is_processed(self):
...@@ -181,37 +160,24 @@ class TestUpdateActivity(TestCase): ...@@ -181,37 +160,24 @@ class TestUpdateActivity(TestCase):
task 6, 7 and 8 are processed, task 6, 7 and 8 are processed,
activity.is_processed should be true and activity status should go to 'aggregate' activity.is_processed should be true and activity status should go to 'aggregate'
""" """
activity = self.task6.activity activity = self.task6.activity
self.assertTrue(activity.is_processed)
actual = activity.is_processed self.assertEqual(activity.status, State.AGGREGATE.value)
self.assertEqual(actual, True)
actual = activity.status
self.assertEqual(actual, State.AGGREGATE.value)
def test_reset_activity(self): def test_reset_activity(self):
""" """
when a task is set to DEFINED or FETCHED, the Activity is reset when a task is set to DEFINED or FETCHED, the Activity is reset
""" """
activity = self.task1.activity activity = self.task1.activity
# simulate post aggregation state # simulate post aggregation state
activity.is_aggregated = True activity.is_aggregated = True
activity.is_processed = True activity.is_processed = True
# check if that worked
actual = activity.is_aggregated
self.assertEqual(actual, True)
# simulate task to FETCHED # simulate task to FETCHED
self.task1.new_status = State.FETCHED.value self.task1.new_status = State.FETCHED.value
self.task1.save() self.task1.save()
# check if the activity is reset # check if the activity is reset
actual = activity.is_aggregated self.assertFalse(activity.is_aggregated)
self.assertEqual(actual, False) self.assertFalse(activity.is_processed)
\ No newline at end of file
actual = activity.is_processed
self.assertEqual(actual, False)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment