File tree 5 files changed +15
-6
lines changed
5 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 2
2
Mock implementation of swsscommon package for unit testing
3
3
'''
4
4
5
+ from swsssdk import ConfigDBConnector , SonicDBConfig , SonicV2Connector
6
+
5
7
STATE_DB = ''
6
8
7
9
Original file line number Diff line number Diff line change 10
10
from unittest import mock
11
11
else :
12
12
import mock
13
- from sonic_py_common import daemon_base
14
13
15
14
from .mock_platform import MockChassis , MockFan , MockPsu
16
15
17
16
SYSLOG_IDENTIFIER = 'psud_test'
18
17
NOT_AVAILABLE = 'N/A'
19
18
20
- daemon_base .db_connect = mock .MagicMock ()
21
19
22
20
tests_path = os .path .dirname (os .path .abspath (__file__ ))
23
21
24
22
# Add mocked_libs path so that the file under test can load mocked modules from there
25
23
mocked_libs_path = os .path .join (tests_path , "mocked_libs" )
26
24
sys .path .insert (0 , mocked_libs_path )
27
25
26
+ from sonic_py_common import daemon_base
27
+ daemon_base .db_connect = mock .MagicMock ()
28
+
28
29
# Add path to the file under test so that we can load it
29
30
modules_path = os .path .dirname (tests_path )
30
31
scripts_path = os .path .join (modules_path , "scripts" )
Original file line number Diff line number Diff line change 11
11
import mock
12
12
from sonic_py_common import daemon_base
13
13
14
- from .mock_platform import MockPsu
14
+ from .mock_platform import MockPsu , MockChassis
15
15
16
16
tests_path = os .path .dirname (os .path .abspath (__file__ ))
17
17
@@ -179,6 +179,7 @@ def test_log_on_status_changed():
179
179
mock_logger .log_warning .assert_called_with (abnormal_log )
180
180
181
181
182
+ @mock .patch ('psud.platform_chassis' , mock .MagicMock ())
182
183
@mock .patch ('psud.DaemonPsud.run' )
183
184
def test_main (mock_run ):
184
185
mock_run .return_value = False
Original file line number Diff line number Diff line change 2
2
Mock implementation of swsscommon package for unit testing
3
3
'''
4
4
5
+ from swsssdk import ConfigDBConnector , SonicDBConfig , SonicV2Connector
6
+
5
7
STATE_DB = ''
6
8
7
9
@@ -23,6 +25,9 @@ def get(self, key):
23
25
return self .mock_dict [key ]
24
26
return None
25
27
28
+ def get_size (self ):
29
+ return (len (self .mock_dict ))
30
+
26
31
27
32
class FieldValuePairs :
28
33
fv_dict = {}
Original file line number Diff line number Diff line change 9
9
from unittest import mock
10
10
else :
11
11
import mock
12
- from sonic_py_common import daemon_base
13
12
14
13
SYSLOG_IDENTIFIER = 'syseepromd_test'
15
14
NOT_AVAILABLE = 'N/A'
16
15
17
- daemon_base .db_connect = mock .MagicMock ()
18
-
19
16
tests_path = os .path .dirname (os .path .abspath (__file__ ))
20
17
21
18
# Add mocked_libs path so that the file under test can load mocked modules from there
22
19
mocked_libs_path = os .path .join (tests_path , 'mocked_libs' )
23
20
sys .path .insert (0 , mocked_libs_path )
24
21
22
+ from sonic_py_common import daemon_base
23
+ daemon_base .db_connect = mock .MagicMock ()
24
+
25
25
# Add path to the file under test so that we can load it
26
26
modules_path = os .path .dirname (tests_path )
27
27
scripts_path = os .path .join (modules_path , 'scripts' )
You can’t perform that action at this time.
0 commit comments