Skip to content

Commit

Permalink
add get_config_db_as_text ut
Browse files Browse the repository at this point in the history
  • Loading branch information
xincunli-sonic committed Jun 6, 2024
1 parent fbbc34e commit c4d20c6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/generic_config_updater/gu_common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ def test_ctor__default_values_set(self):

self.assertEqual("/usr/local/yang-models", gu_common.YANG_DIR)

@patch('generic_config_updater.gu_common.subprocess.Popen')
def test_get_config_db_as_text(self, mock_popen):
config_wrapper = gu_common.ConfigWrapper()
mock_proc = MagicMock()
mock_proc.communicate = MagicMock(
return_value=("[]", None))
mock_proc.returncode = 0
mock_popen.return_value = mock_proc
actual = config_wrapper._get_config_db_as_text()
expected = "[]"
self.assertEqual(actual, expected)

config_wrapper = gu_common.ConfigWrapper(scope="asic0")
mock_proc = MagicMock()
mock_proc.communicate = MagicMock(
return_value=("[]", None))
mock_proc.returncode = 0
mock_popen.return_value = mock_proc
actual = config_wrapper._get_config_db_as_text()
expected = "[]"
self.assertEqual(actual, expected)

def test_get_sonic_yang_as_json__returns_sonic_yang_as_json(self):
# Arrange
config_wrapper = self.config_wrapper_mock
Expand Down

0 comments on commit c4d20c6

Please sign in to comment.