Skip to content

Commit

Permalink
[IBCDPE-1066] Updates gx_enabled logic (#147)
Browse files Browse the repository at this point in the history
* updates gx_enabled logic

* updates tests to include
  • Loading branch information
BWMac authored Aug 26, 2024
1 parent 5d85d94 commit 3728f75
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/agoradatatools/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def process_dataset(
filename=dataset_name + "." + dataset_obj[dataset_name]["final_format"],
)

gx_enabled = "gx_enabled" in dataset_obj[dataset_name].keys()
gx_enabled = dataset_obj[dataset_name].get("gx_enabled", False)

if gx_enabled:
gx_runner = GreatExpectationsRunner(
Expand Down
28 changes: 21 additions & 7 deletions tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@ class TestProcessDataset:
}
}

def setup_method(self, syn):
dataset_object_gx_disabled = {
"neuropath_corr": {
"files": [{"name": "test_file_1", "id": "syn1111111", "format": "csv"}],
"final_format": "json",
"provenance": ["syn1111111"],
"destination": "syn1111113",
"gx_enabled": False,
}
}

def setup_method(self):
self.patch_get_entity_as_df = patch.object(
extract, "get_entity_as_df", return_value=pd.DataFrame
).start()
Expand Down Expand Up @@ -114,7 +124,7 @@ def teardown_method(self):
self.patch_format_link.stop()
mock.patch.stopall()

def test_process_dataset_upload_false_gx_disabled(self, syn: Any):
def test_process_dataset_upload_false_gx_not_specified(self, syn: Any):
process.process_dataset(
dataset_obj=self.dataset_object,
staging_path=STAGING_PATH,
Expand Down Expand Up @@ -142,7 +152,9 @@ def test_process_dataset_upload_false_gx_disabled(self, syn: Any):
self.patch_format_link.assert_not_called()
self.patch_load.assert_not_called()

def test_process_dataset_upload_false_gx_disabled_column_rename(self, syn: Any):
def test_process_dataset_upload_false_gx_not_specified_column_rename(
self, syn: Any
):
process.process_dataset(
dataset_obj=self.dataset_object_col_rename,
staging_path=STAGING_PATH,
Expand Down Expand Up @@ -172,7 +184,7 @@ def test_process_dataset_upload_false_gx_disabled_column_rename(self, syn: Any):
self.patch_format_link.assert_not_called()
self.patch_load.assert_not_called()

def test_process_dataset_upload_false_gx_disabled_custom_transformations(
def test_process_dataset_upload_false_gx_not_specified_custom_transformations(
self, syn: Any
):
process.process_dataset(
Expand Down Expand Up @@ -214,7 +226,9 @@ def test_process_dataset_upload_false_gx_disabled_custom_transformations(

# This test looks like a duplicate of test_process_dataset_upload_false_gx_disabled
# but it uses the agora_rename configuration with the same util function
def test_process_dataset_upload_false_gx_disabled_with_agora_rename(self, syn: Any):
def test_process_dataset_upload_false_gx_not_specified_with_agora_rename(
self, syn: Any
):
process.process_dataset(
dataset_obj=self.dataset_object_col_rename,
staging_path=STAGING_PATH,
Expand Down Expand Up @@ -244,7 +258,7 @@ def test_process_dataset_upload_false_gx_disabled_with_agora_rename(self, syn: A
self.patch_format_link.assert_not_called()
self.patch_load.assert_not_called()

def test_process_dataset_upload_false_gx_disabled_type_dict(self, syn: Any):
def test_process_dataset_upload_false_gx_not_specified_type_dict(self, syn: Any):
self.patch_standardize_values.return_value = dict()
process.process_dataset(
dataset_obj=self.dataset_object,
Expand Down Expand Up @@ -275,7 +289,7 @@ def test_process_dataset_upload_false_gx_disabled_type_dict(self, syn: Any):

def test_process_dataset_upload_true_gx_disabled(self, syn: Any):
process.process_dataset(
dataset_obj=self.dataset_object,
dataset_obj=self.dataset_object_gx_disabled,
staging_path=STAGING_PATH,
gx_folder=GX_FOLDER,
syn=syn,
Expand Down

0 comments on commit 3728f75

Please sign in to comment.