Commit 449f5994 authored by Paul Graydon's avatar Paul Graydon

wendelin_telecom_test: Test additional cases for ORS Data Supply scripts

parent 683079e2
...@@ -104,6 +104,13 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -104,6 +104,13 @@ class WendelinTelecomTest(SecurityTestCase):
module.manage_delObjects(ids=test_object_id_list) module.manage_delObjects(ids=test_object_id_list)
self.tic() self.tic()
def _removeDocument(self, document_to_remove):
path = document_to_remove.getRelativeUrl()
container, _, object_id = path.rpartition('/')
parent = self.portal.unrestrictedTraverse(container)
parent.manage_delObjects([object_id])
self.commit()
def createWendelinTelecomUser(self, reference, project, function): def createWendelinTelecomUser(self, reference, project, function):
# Create and validate a new Person with an assignment # Create and validate a new Person with an assignment
# linked to the provided project and function # linked to the provided project and function
...@@ -629,6 +636,9 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -629,6 +636,9 @@ class WendelinTelecomTest(SecurityTestCase):
''' '''
Test the action which creates an ORS Data Supply from a Data Acquisition Unit. Test the action which creates an ORS Data Supply from a Data Acquisition Unit.
Check that the Data Supply is indeed created and validated. Check that the Data Supply is indeed created and validated.
Also check pathological cases considered by the script:
- Data Acquisition Unit has no reference
- Several Data Supplies exist for a Data Acquisition Unit.
''' '''
reference = 'test_%s' % generateRandomString() reference = 'test_%s' % generateRandomString()
...@@ -652,7 +662,32 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -652,7 +662,32 @@ class WendelinTelecomTest(SecurityTestCase):
retrieved_data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1) retrieved_data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1)
# Check that both Data Supplies are identical # Check that both Data Supplies are identical
self.assertTrue(created_data_supply == retrieved_data_supply) self.assertTrue(retrieved_data_supply == created_data_supply)
# Pathological case: create another identical Data Supply
created_data_supply.invalidate()
self.tic()
data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1)
created_data_supply.validate()
self.tic()
re_retrieved_data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1)
self.assertTrue(re_retrieved_data_supply == created_data_supply)
# Pathological case: create a Data Acquisition Unit without a reference
data_acquisition_unit = self.portal.data_acquisition_unit_module.newContent(
portal_type='Data Acquisition Unit',
)
data_acquisition_unit.validate()
self.tic()
self.addCleanup(self._removeDocument, data_acquisition_unit)
# Call the script which should NOT create a Data Supply (no reference to copy over)
none_data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1)
self.tic()
self.assertTrue(none_data_supply is None)
def test_02_registerOrsClientProject(self): def test_02_registerOrsClientProject(self):
''' '''
...@@ -1260,7 +1295,7 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -1260,7 +1295,7 @@ class WendelinTelecomTest(SecurityTestCase):
# except for the last three # except for the last three
ingestion_item_dict_list = [ ingestion_item_dict_list = [
self.getOrsLogIngestionItems( self.getOrsLogIngestionItems(
self.test_ors_example_log_valid, self.test_ors_example_log_empty,
ors_item_dict['data_acquisition_unit'].getReference() ors_item_dict['data_acquisition_unit'].getReference()
) )
for ors_item_dict in ors_item_dict_list[:7] for ors_item_dict in ors_item_dict_list[:7]
...@@ -1617,7 +1652,7 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -1617,7 +1652,7 @@ class WendelinTelecomTest(SecurityTestCase):
# except for the last one # except for the last one
ingestion_item_dict_list = [ ingestion_item_dict_list = [
self.getOrsLogIngestionItems( self.getOrsLogIngestionItems(
self.test_ors_example_log_valid, self.test_ors_example_log_empty,
ors_item_dict['data_acquisition_unit'].getReference() ors_item_dict['data_acquisition_unit'].getReference()
) )
for ors_item_dict in ors_item_dict_list[:-1] for ors_item_dict in ors_item_dict_list[:-1]
...@@ -1942,7 +1977,7 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -1942,7 +1977,7 @@ class WendelinTelecomTest(SecurityTestCase):
# Perform a data ingestion for each ORS # Perform a data ingestion for each ORS
ingestion_item_dict_list = [ ingestion_item_dict_list = [
self.getOrsLogIngestionItems( self.getOrsLogIngestionItems(
self.test_ors_example_log_valid, self.test_ors_example_log_empty,
ors_item_dict['data_acquisition_unit'].getReference() ors_item_dict['data_acquisition_unit'].getReference()
) )
for ors_item_dict in ors_item_dict_list for ors_item_dict in ors_item_dict_list
...@@ -2068,15 +2103,15 @@ class WendelinTelecomTest(SecurityTestCase): ...@@ -2068,15 +2103,15 @@ class WendelinTelecomTest(SecurityTestCase):
# Perform ingestions for all three ORSs # Perform ingestions for all three ORSs
ingestion_a_item_dict = self.getOrsLogIngestionItems( ingestion_a_item_dict = self.getOrsLogIngestionItems(
self.test_ors_example_log_valid, self.test_ors_example_log_empty,
ors_a_tag ors_a_tag
) )
ingestion_b_item_dict = self.getOrsLogIngestionItems( ingestion_b_item_dict = self.getOrsLogIngestionItems(
self.test_ors_example_log_valid, self.test_ors_example_log_empty,
ors_b_tag ors_b_tag
) )
ingestion_n_item_dict = self.getOrsLogIngestionItems( ingestion_n_item_dict = self.getOrsLogIngestionItems(
self.test_ors_example_log_valid, self.test_ors_example_log_empty,
ors_n_tag ors_n_tag
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment