Skip to content

Commit

Permalink
Fix vrf UT failed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 committed Aug 12, 2022
1 parent 28b6ba5 commit 9e37655
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/ip_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,31 @@ def test_remove_interface_case_sensitive_mock_ipv6_w_apply_patch(self):
print(result.exit_code, result.output)
assert "converted ipv6 address to lowercase fc00::1~1126 with prefix /INTERFACE/Ethernet12| in value: /INTERFACE/Ethernet12|FC00::1~1126" in result.output

def test_intf_vrf_bind_unbind(self):
runner = CliRunner()
db = Db()
obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}

result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf1"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0

result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet64"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0

def test_intf_vrf_bind_unbind(self):
runner = CliRunner()
db = Db()
obj = {'config_db':db.cfgdb, 'namespace':db.db.namespace}

result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["bind"], ["Ethernet64", "Vrf1"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0

result = runner.invoke(config.config.commands["interface"].commands["vrf"].commands["unbind"], ["Ethernet64"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code == 0

@classmethod
def teardown_class(cls):
Expand Down
3 changes: 3 additions & 0 deletions tests/mock_tables/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def connect_SonicV2Connector(self, db_name, retry_on=True):
def _subscribe_keyspace_notification(self, db_name, client):
pass

def mock_close(self, db_name):
pass

def config_set(self, *args):
pass
Expand Down Expand Up @@ -201,6 +203,7 @@ def get(self, counter, name):


swsssdk.interface.DBInterface._subscribe_keyspace_notification = _subscribe_keyspace_notification
swsssdk.interface.DBInterface.close = mock_close
mockredis.MockRedis.config_set = config_set
redis.StrictRedis = SwssSyncClient
SonicV2Connector.connect = connect_SonicV2Connector
Expand Down

0 comments on commit 9e37655

Please sign in to comment.