File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 Mock implementation of swsscommon package for unit testing
33'''
44
5+ from swsssdk import ConfigDBConnector , SonicDBConfig , SonicV2Connector
6+
57STATE_DB = ''
68
79
Original file line number Diff line number Diff line change 1010 from unittest import mock
1111else :
1212 import mock
13- from sonic_py_common import daemon_base
1413
1514from .mock_platform import MockChassis , MockFan , MockPsu
1615
1716SYSLOG_IDENTIFIER = 'psud_test'
1817NOT_AVAILABLE = 'N/A'
1918
20- daemon_base .db_connect = mock .MagicMock ()
2119
2220tests_path = os .path .dirname (os .path .abspath (__file__ ))
2321
2422# Add mocked_libs path so that the file under test can load mocked modules from there
2523mocked_libs_path = os .path .join (tests_path , "mocked_libs" )
2624sys .path .insert (0 , mocked_libs_path )
2725
26+ from sonic_py_common import daemon_base
27+ daemon_base .db_connect = mock .MagicMock ()
28+
2829# Add path to the file under test so that we can load it
2930modules_path = os .path .dirname (tests_path )
3031scripts_path = os .path .join (modules_path , "scripts" )
Original file line number Diff line number Diff line change 1111 import mock
1212from sonic_py_common import daemon_base
1313
14- from .mock_platform import MockPsu
14+ from .mock_platform import MockPsu , MockChassis
1515
1616tests_path = os .path .dirname (os .path .abspath (__file__ ))
1717
@@ -179,6 +179,7 @@ def test_log_on_status_changed():
179179 mock_logger .log_warning .assert_called_with (abnormal_log )
180180
181181
182+ @mock .patch ('psud.platform_chassis' , mock .MagicMock ())
182183@mock .patch ('psud.DaemonPsud.run' )
183184def test_main (mock_run ):
184185 mock_run .return_value = False
Original file line number Diff line number Diff line change 22 Mock implementation of swsscommon package for unit testing
33'''
44
5+ from swsssdk import ConfigDBConnector , SonicDBConfig , SonicV2Connector
6+
57STATE_DB = ''
68
79
@@ -23,6 +25,9 @@ def get(self, key):
2325 return self .mock_dict [key ]
2426 return None
2527
28+ def get_size (self ):
29+ return (len (self .mock_dict ))
30+
2631
2732class FieldValuePairs :
2833 fv_dict = {}
Original file line number Diff line number Diff line change 99 from unittest import mock
1010else :
1111 import mock
12- from sonic_py_common import daemon_base
1312
1413SYSLOG_IDENTIFIER = 'syseepromd_test'
1514NOT_AVAILABLE = 'N/A'
1615
17- daemon_base .db_connect = mock .MagicMock ()
18-
1916tests_path = os .path .dirname (os .path .abspath (__file__ ))
2017
2118# Add mocked_libs path so that the file under test can load mocked modules from there
2219mocked_libs_path = os .path .join (tests_path , 'mocked_libs' )
2320sys .path .insert (0 , mocked_libs_path )
2421
22+ from sonic_py_common import daemon_base
23+ daemon_base .db_connect = mock .MagicMock ()
24+
2525# Add path to the file under test so that we can load it
2626modules_path = os .path .dirname (tests_path )
2727scripts_path = os .path .join (modules_path , 'scripts' )
You can’t perform that action at this time.
0 commit comments