Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
Prev Previous commit
Next Next commit
Use Path with mocks
  • Loading branch information
dbeatty10 committed Feb 27, 2023
commit 813018a5740f86eef1910015e84d07efbf3e4a98
26 changes: 13 additions & 13 deletions tests/test_dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_get_datadiff_variables_empty(self):
def test_get_models(self, mock_manifest_parser, mock_run_parser, mock_open):
expected_value = "expected_value"
mock_self = Mock()
mock_self.project_dir = ""
mock_self.project_dir = Path()
mock_run_results = Mock()
mock_success_result = Mock()
mock_failed_result = Mock()
Expand Down Expand Up @@ -82,7 +82,7 @@ def test_get_models(self, mock_manifest_parser, mock_run_parser, mock_open):
@patch("data_diff.dbt.parse_manifest")
def test_get_models_bad_lower_dbt_version(self, mock_manifest_parser, mock_run_parser, mock_open):
mock_self = Mock()
mock_self.project_dir = ""
mock_self.project_dir = Path()
mock_run_results = Mock()
mock_run_parser.return_value = mock_run_results
mock_run_results.metadata.dbt_version = "0.19.0"
Expand All @@ -100,7 +100,7 @@ def test_get_models_bad_lower_dbt_version(self, mock_manifest_parser, mock_run_p
@patch("data_diff.dbt.parse_manifest")
def test_get_models_bad_upper_dbt_version(self, mock_manifest_parser, mock_run_parser, mock_open):
mock_self = Mock()
mock_self.project_dir = ""
mock_self.project_dir = Path()
mock_run_results = Mock()
mock_run_parser.return_value = mock_run_results
mock_run_results.metadata.dbt_version = "1.5.1"
Expand All @@ -118,7 +118,7 @@ def test_get_models_bad_upper_dbt_version(self, mock_manifest_parser, mock_run_p
@patch("data_diff.dbt.parse_manifest")
def test_get_models_no_success(self, mock_manifest_parser, mock_run_parser, mock_open):
mock_self = Mock()
mock_self.project_dir = ""
mock_self.project_dir = Path()
mock_run_results = Mock()
mock_success_result = Mock()
mock_failed_result = Mock()
Expand All @@ -145,7 +145,7 @@ def test_get_models_no_success(self, mock_manifest_parser, mock_run_parser, mock
def test_set_project_dict(self, mock_open, mock_yaml_parse):
expected_dict = {"key1": "value1"}
mock_self = Mock()
mock_self.project_dir = ""
mock_self.project_dir = Path()
mock_yaml_parse.return_value = expected_dict
DbtParser.set_project_dict(mock_self)

Expand All @@ -170,7 +170,7 @@ def test_set_connection_snowflake(self, mock_open_file, mock_yaml_parse):
}

mock_self = Mock()
mock_self.profiles_dir = ""
mock_self.profiles_dir = Path()
mock_self.project_dict = {"profile": "profile_name"}
mock_yaml_parse.return_value = profiles_dict
DbtParser.set_connection(mock_self)
Expand All @@ -194,7 +194,7 @@ def test_set_connection_snowflake_no_password(self, mock_open_file, mock_yaml_pa
}

mock_self = Mock()
mock_self.profiles_dir = ""
mock_self.profiles_dir = Path()
mock_self.project_dict = {"profile": "profile_name"}
mock_yaml_parse.return_value = profiles_dict

Expand Down Expand Up @@ -227,7 +227,7 @@ def test_set_connection_bigquery(self, mock_open_file, mock_yaml_parse):
}

mock_self = Mock()
mock_self.profiles_dir = ""
mock_self.profiles_dir = Path()
mock_self.project_dict = {"profile": "profile_name"}
mock_yaml_parse.return_value = profiles_dict
DbtParser.set_connection(mock_self)
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_set_connection_bigquery_not_oauth(self, mock_open_file, mock_yaml_parse
}

mock_self = Mock()
mock_self.profiles_dir = ""
mock_self.profiles_dir = Path()
mock_self.project_dict = {"profile": "profile_name"}
mock_yaml_parse.return_value = profiles_dict
with self.assertRaises(Exception):
Expand All @@ -287,8 +287,8 @@ def test_set_connection_key_error(self, mock_open_file, mock_yaml_parse):
}

mock_self = Mock()
mock_self.profiles_dir = ""
mock_self.project_dir = ""
mock_self.profiles_dir = Path()
mock_self.project_dir = Path()
mock_self.project_dict = {"profile": "bad_key"}
mock_yaml_parse.return_value = profiles_dict
with self.assertRaises(Exception):
Expand All @@ -314,8 +314,8 @@ def test_set_connection_not_implemented(self, mock_open_file, mock_yaml_parse):
}

mock_self = Mock()
mock_self.profiles_dir = ""
mock_self.project_dir = ""
mock_self.profiles_dir = Path()
mock_self.project_dir = Path()
mock_self.project_dict = {"profile": "profile_name"}
mock_yaml_parse.return_value = profiles_dict
with self.assertRaises(NotImplementedError):
Expand Down