Skip to content

Commit

Permalink
ACAS-773 add failing test for special character protocol and expt names
Browse files Browse the repository at this point in the history
  • Loading branch information
bffrost committed Jun 3, 2024
1 parent bdba56f commit 480f766
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
34 changes: 30 additions & 4 deletions tests/test_acasclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2932,9 +2932,27 @@ def test_056_additional_assay_scientists(self):
# Verify the scientist is the same as we specified
experiment = Experiment(experiment_dict)
self.assertEqual(experiment.scientist, new_assay_scientist_code)


def get_basic_experiment_load_file(tempdir, project_code=None, corp_name=None, file_name=None, scientist=None):

@requires_basic_cmpd_reg_load
def test_057_get_protocol_expt_special_characters_in_names(self):
"""Test getting protocols and experiments with special characters in their names."""
protocol_name = "test/protocol.name !@#$%^&*(special/chars)"
experiment_name = "test/experiment.name !@#$%^&*(special/chars)"
file_to_upload = get_basic_experiment_load_file(self.tempdir, protocol_name=protocol_name, experiment_name=experiment_name)
response = self.client.\
experiment_loader(file_to_upload, "bob", False)
# Search for the protocol by name
res = self.client.protocol_search(protocol_name)
self.assertEqual(len(res), 1)
# Get the protocol by name
res = self.client.get_protocols_by_label(protocol_name)
self.assertEqual(len(res), 1)
# Get the experiment by name
expt = self.client.get_experiment_by_name(experiment_name)
self.assertIsNotNone(expt)


def get_basic_experiment_load_file(tempdir, project_code=None, corp_name=None, file_name=None, scientist=None, protocol_name=None, experiment_name=None):
if file_name is None:
file_name = 'uniform-commas-with-quoted-text.csv'
data_file_to_upload = Path(__file__).resolve()\
Expand All @@ -2954,6 +2972,14 @@ def get_basic_experiment_load_file(tempdir, project_code=None, corp_name=None, f
# If scientist is specified, replace the scientist
if scientist is not None:
data_file_contents = data_file_contents.replace('bob', scientist)

# If protocol name is specified, replace the protocol name
if protocol_name is not None:
data_file_contents = data_file_contents.replace('PROTOCOL_BLAH', protocol_name)

# If experiment name is specified, replace the experiment name
if experiment_name is not None:
data_file_contents = data_file_contents.replace('EXPERIMENT_BLAH', experiment_name)

# Write the data file to the temp dir
file_name = f'basic-experiment-{ str(uuid.uuid4())}.csv'
Expand Down Expand Up @@ -3067,7 +3093,7 @@ def test_002_get_lot_dependencies(self, experiment):
self.assertEqual(len(meta_lot_dependencies['linkedExperiments']), 1)
protocol = meta_lot_dependencies['linkedExperiments'][0]['protocol']
self.assertIn('code', protocol)
self.assertEqual(protocol['name'], 'BLAH')
self.assertEqual(protocol['name'], 'PROTOCOL_BLAH')

# Verify the analysis group information
self.assertEqual(len(meta_lot_dependencies['linkedExperiments']), 1)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_acasclient/uniform-commas-with-quoted-text.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Experiment Meta Data,,,
Format,Generic,,
Protocol Name,BLAH,,
Experiment Name,BLAH,,
Protocol Name,PROTOCOL_BLAH,,
Experiment Name,EXPERIMENT_BLAH,,
Scientist,bob,,
Notebook,BLAH,,
Notebook,NOTEBOOK_BLAH,,
Page,,,
Assay Date,2022-03-30,,
Project,Global,,
Expand Down

0 comments on commit 480f766

Please sign in to comment.