Skip to content

Commit

Permalink
resolved function error
Browse files Browse the repository at this point in the history
  • Loading branch information
kanza-latif committed Sep 10, 2024
1 parent 0dc74c8 commit dcf37a3
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions tests/hostcfgd/hostcfgd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,30 +295,30 @@ def test_dns_events(self):
mocked_run_cmd.assert_has_calls([call(['systemctl', 'restart', 'resolv-config'], True, False)])

def test_memory_statistics_event(self):
MockConfigDb.set_config_db(HOSTCFG_DAEMON_CFG_DB)
daemon = hostcfgd.HostConfigDaemon()
daemon.register_callbacks()
MockConfigDb.event_queue = [('MEMORY_STATISTICS', 'config')]

with mock.patch('hostcfgd.subprocess') as mocked_subprocess:
popen_mock = mock.Mock()
attrs = {'communicate.return_value': ('output', 'error')}
popen_mock.configure_mock(**attrs)
mocked_subprocess.Popen.return_value = popen_mock
mocked_subprocess.check_call = mock.Mock()

try:
daemon.start()
except TimeoutError:
pass

expected = [
mock.call(['sonic-memory_statistics-config', '--enable']),
mock.call(['sonic-memory_statistics-config', '--retention_time', '15']),
mock.call(['sonic-memory_statistics-config', '--sampling_interval', '5'])
]
MockConfigDb.set_config_db(HOSTCFG_DAEMON_CFG_DB)
daemon = hostcfgd.HostConfigDaemon()
daemon.register_callbacks()
MockConfigDb.event_queue = [('MEMORY_STATISTICS', 'config')]

mocked_subprocess.check_call.assert_has_calls(expected, any_order=True)
with mock.patch('hostcfgd.subprocess') as mocked_subprocess:
popen_mock = mock.Mock()
attrs = {'communicate.return_value': ('output', 'error')}
popen_mock.configure_mock(**attrs)
mocked_subprocess.Popen.return_value = popen_mock
mocked_subprocess.check_call = mock.Mock()

try:
daemon.start()
except TimeoutError:
pass

expected = [
mock.call(['sonic-memory_statistics-config', '--enable']),
mock.call(['sonic-memory_statistics-config', '--retention_time', '15']),
mock.call(['sonic-memory_statistics-config', '--sampling_interval', '5'])
]

mocked_subprocess.check_call.assert_has_calls(expected, any_order=True)


class TestDnsHandler:
Expand Down

0 comments on commit dcf37a3

Please sign in to comment.