Commit f09bd31
authored
Fix UT failed cause by change pycommon to use swsscommon (#246)
Fix UT failed cause by change sonic_py_common to use swss_common
#### Description
Fix UT failed cause by change sonic_py_common to use swss_common:
In current UT, we implement swsscommon mock class under sonic-pcied/tests/mocked_libs/swsscommon and load these mock libs by add the mock path in front of real swsscommon lib path with following code:
# Add mocked_libs path so that the file under test can load mocked modules from there
mocked_libs_path = os.path.join(tests_path, "mocked_libs")
sys.path.insert(0, mocked_libs_path)
However, because we change sonic_py_common to use swsscommon, so real version of swsscommon been load before we load mock lib. then the UT break with following error message:
______________ TestDaemonPcied.test_update_pcie_devices_status_db ______________
self = <tests.test_DaemonPcied.TestDaemonPcied object at 0x7f29542655d0>
@mock.patch('pcied.load_platform_pcieutil', mock.MagicMock())
def test_update_pcie_devices_status_db(self):
> daemon_pcied = pcied.DaemonPcied(SYSLOG_IDENTIFIER)
tests/test_DaemonPcied.py:160:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
scripts/pcied:93: in __init__
self.device_table = swsscommon.Table(self.state_db, PCIE_DEVICE_TABLE_NAME)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swsscommon.swsscommon.Table; >
args = (<MagicMock name='mock()' id='139815470171344'>, 'PCIE_DEVICE')
def __init__(self, *args):
> this = _swsscommon.new_Table(*args)
E NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Table'.
E Possible C/C++ prototypes are:
E swss::Table::Table(swss::DBConnector const *,std::string const &)
E swss::Table::Table(swss::RedisPipeline *,std::string const &,bool)
#### Motivation and Context
pyswss will be deprecate, so sonic_py_common will changed to use swss_common.
Some UT in this project failed because this change.
#### How Has This Been Tested?
Pass all UT and sonic-buildimage E2E test.
#### Additional Information (Optional)1 parent c092300 commit f09bd31
3 files changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | | - | |
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments