Skip to content

Commit 21c4da0

Browse files
bhouse-nexthopbradh352
authored andcommitted
fix test cases due to removal of import in change_applier
1 parent 9505928 commit 21c4da0

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

tests/generic_config_updater/gcu_feature_patch_application_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,9 @@ def create_patch_applier(self, config):
9494
patch_wrapper = PatchWrapper(config_wrapper)
9595
return gu.PatchApplier(config_wrapper=config_wrapper, patch_wrapper=patch_wrapper, changeapplier=change_applier)
9696

97-
@patch('generic_config_updater.change_applier.get_config_db_as_json', side_effect=get_running_config)
9897
@patch("generic_config_updater.change_applier.get_config_db")
9998
@patch("generic_config_updater.change_applier.set_config")
100-
def run_single_success_case_applier(self, data, mock_set, mock_db, mock_get_config_db_as_json):
99+
def run_single_success_case_applier(self, data, mock_set, mock_db):
101100
current_config = data["current_config"]
102101
expected_config = data["expected_config"]
103102
patch = jsonpatch.JsonPatch(data["patch"])
@@ -125,8 +124,7 @@ def run_single_success_case_applier(self, data, mock_set, mock_db, mock_get_conf
125124
self.assertEqual(simulated_config, expected_config)
126125

127126
@patch("generic_config_updater.change_applier.get_config_db")
128-
@patch('generic_config_updater.change_applier.get_config_db_as_json', side_effect=get_running_config)
129-
def run_single_failure_case_applier(self, data, mock_db, mock_get_config_db_as_json):
127+
def run_single_failure_case_applier(self, data, mock_db):
130128
current_config = data["current_config"]
131129
patch = jsonpatch.JsonPatch(data["patch"])
132130
expected_error_substrings = data["expected_error_substrings"]

tests/generic_config_updater/multiasic_change_applier_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_extract_scope_singleasic(self, mock_is_multi_asic):
178178
except jsonpointer.JsonPointerException:
179179
assert(not result)
180180

181-
@patch('generic_config_updater.change_applier.get_config_db_as_json', autospec=True)
181+
@patch('generic_config_updater.gu_common.get_config_db_as_json', autospec=True)
182182
@patch('generic_config_updater.change_applier.ConfigDBConnector', autospec=True)
183183
def test_apply_change_default_scope(self, mock_ConfigDBConnector, mock_get_running_config):
184184
# Setup mock for ConfigDBConnector
@@ -195,13 +195,13 @@ def test_apply_change_default_scope(self, mock_ConfigDBConnector, mock_get_runni
195195
change = MagicMock()
196196

197197
# Call the apply method with the change object
198-
current_config = copy.deepcopy(generic_config_updater.change_applier.get_config_db_as_json(scope=self))
198+
current_config = copy.deepcopy(generic_config_updater.gu_common.get_config_db_as_json(scope=self))
199199
current_config = applier.apply(current_config, change)
200200

201201
# Assert ConfigDBConnector called with the correct namespace
202202
mock_ConfigDBConnector.assert_called_once_with(use_unix_socket_path=True, namespace="")
203203

204-
@patch('generic_config_updater.change_applier.get_config_db_as_json', autospec=True)
204+
@patch('generic_config_updater.gu_common.get_config_db_as_json', autospec=True)
205205
@patch('generic_config_updater.change_applier.ConfigDBConnector', autospec=True)
206206
def test_apply_change_given_scope(self, mock_ConfigDBConnector, mock_get_running_config):
207207
# Setup mock for ConfigDBConnector
@@ -216,13 +216,13 @@ def test_apply_change_given_scope(self, mock_ConfigDBConnector, mock_get_running
216216
change = MagicMock()
217217

218218
# Call the apply method with the change object
219-
current_config = copy.deepcopy(generic_config_updater.change_applier.get_config_db_as_json(scope="asic0"))
219+
current_config = copy.deepcopy(generic_config_updater.gu_common.get_config_db_as_json(scope="asic0"))
220220
current_config = applier.apply(current_config, change)
221221

222222
# Assert ConfigDBConnector called with the correct scope
223223
mock_ConfigDBConnector.assert_called_once_with(use_unix_socket_path=True, namespace="asic0")
224224

225-
@patch('generic_config_updater.change_applier.get_config_db_as_json', autospec=True)
225+
@patch('generic_config_updater.gu_common.get_config_db_as_json', autospec=True)
226226
@patch('generic_config_updater.change_applier.ConfigDBConnector', autospec=True)
227227
def test_apply_change_failure(self, mock_ConfigDBConnector, mock_get_running_config):
228228
# Setup mock for ConfigDBConnector
@@ -240,12 +240,12 @@ def test_apply_change_failure(self, mock_ConfigDBConnector, mock_get_running_con
240240

241241
# Test the behavior when os.system fails
242242
with self.assertRaises(Exception) as context:
243-
current_config = copy.deepcopy(generic_config_updater.change_applier.get_config_db_as_json())
243+
current_config = copy.deepcopy(generic_config_updater.gu_common.get_config_db_as_json())
244244
current_config = applier.apply(current_config, change)
245245

246246
self.assertTrue('Failed to get running config' in str(context.exception))
247247

248-
@patch('generic_config_updater.change_applier.get_config_db_as_json', autospec=True)
248+
@patch('generic_config_updater.gu_common.get_config_db_as_json', autospec=True)
249249
@patch('generic_config_updater.change_applier.ConfigDBConnector', autospec=True)
250250
def test_apply_patch_with_empty_tables_failure(self, mock_ConfigDBConnector, mock_get_running_config):
251251
# Setup mock for ConfigDBConnector
@@ -271,7 +271,7 @@ def mock_get_empty_running_config_side_effect():
271271
# Prepare a change object or data that applier.apply would use, simulating a patch that requires non-empty tables
272272
change = MagicMock()
273273

274-
current_config = copy.deepcopy(generic_config_updater.change_applier.get_config_db_as_json())
274+
current_config = copy.deepcopy(generic_config_updater.gu_common.get_config_db_as_json())
275275

276276
# Apply the patch
277277
try:

0 commit comments

Comments
 (0)