Skip to content

Commit 1542e7a

Browse files
liuh-80yxieca
authored andcommitted
Fix vrf UT failed issue (#2309)
#### What I did Fix VRF bind/unbind UT failed issue. #### How I did it Mock DBInterface.close() method. #### How to verify it Add new UT. Pass all UT. #### Previous command output (if the output of a command-line utility has changed) #### New command output (if the output of a command-line utility has changed)
1 parent ec4b09f commit 1542e7a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/ip_config_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ def test_remove_interface_case_sensitive_mock_ipv6_w_apply_patch(self):
177177
print(result.exit_code, result.output)
178178
assert "converted ipv6 address to lowercase fc00::1~1126 with prefix /INTERFACE/Ethernet12| in value: /INTERFACE/Ethernet12|FC00::1~1126" in result.output
179179

180+
def test_intf_vrf_bind_unbind(self):
181+
runner = CliRunner()
182+
db = Db()
183+
obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}
184+
185+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf1"], obj=obj)
186+
print(result.exit_code, result.output)
187+
assert result.exit_code == 0
188+
189+
result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet64"], obj=obj)
190+
print(result.exit_code, result.output)
191+
assert result.exit_code == 0
180192

181193
@classmethod
182194
def teardown_class(cls):

tests/mock_tables/dbconnector.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def connect_SonicV2Connector(self, db_name, retry_on=True):
6060
def _subscribe_keyspace_notification(self, db_name, client):
6161
pass
6262

63+
def mock_close(self, db_name):
64+
pass
6365

6466
def config_set(self, *args):
6567
pass
@@ -183,6 +185,7 @@ def keys(self, pattern='*'):
183185

184186

185187
swsssdk.interface.DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification
188+
swsssdk.interface.DBInterface.close = mock_close
186189
mockredis.MockRedis.config_set = config_set
187190
redis.StrictRedis = SwssSyncClient
188191
SonicV2Connector.connect = connect_SonicV2Connector

0 commit comments

Comments
 (0)