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):
module.manage_delObjects(ids=test_object_id_list)
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):
# Create and validate a new Person with an assignment
# linked to the provided project and function
......@@ -629,6 +636,9 @@ class WendelinTelecomTest(SecurityTestCase):
'''
Test the action which creates an ORS Data Supply from a Data Acquisition Unit.
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()
......@@ -652,7 +662,32 @@ class WendelinTelecomTest(SecurityTestCase):
retrieved_data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1)
# 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):
'''
......@@ -1260,7 +1295,7 @@ class WendelinTelecomTest(SecurityTestCase):
# except for the last three
ingestion_item_dict_list = [
self.getOrsLogIngestionItems(
self.test_ors_example_log_valid,
self.test_ors_example_log_empty,
ors_item_dict['data_acquisition_unit'].getReference()
)
for ors_item_dict in ors_item_dict_list[:7]
......@@ -1617,7 +1652,7 @@ class WendelinTelecomTest(SecurityTestCase):
# except for the last one
ingestion_item_dict_list = [
self.getOrsLogIngestionItems(
self.test_ors_example_log_valid,
self.test_ors_example_log_empty,
ors_item_dict['data_acquisition_unit'].getReference()
)
for ors_item_dict in ors_item_dict_list[:-1]
......@@ -1942,7 +1977,7 @@ class WendelinTelecomTest(SecurityTestCase):
# Perform a data ingestion for each ORS
ingestion_item_dict_list = [
self.getOrsLogIngestionItems(
self.test_ors_example_log_valid,
self.test_ors_example_log_empty,
ors_item_dict['data_acquisition_unit'].getReference()
)
for ors_item_dict in ors_item_dict_list
......@@ -2068,15 +2103,15 @@ class WendelinTelecomTest(SecurityTestCase):
# Perform ingestions for all three ORSs
ingestion_a_item_dict = self.getOrsLogIngestionItems(
self.test_ors_example_log_valid,
self.test_ors_example_log_empty,
ors_a_tag
)
ingestion_b_item_dict = self.getOrsLogIngestionItems(
self.test_ors_example_log_valid,
self.test_ors_example_log_empty,
ors_b_tag
)
ingestion_n_item_dict = self.getOrsLogIngestionItems(
self.test_ors_example_log_valid,
self.test_ors_example_log_empty,
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