Skip to content

Commit

Permalink
Replace swsssdk.SonicV2Connector with swsscommon.SonicV2Connector (SW…
Browse files Browse the repository at this point in the history
…IG wrapper of C++ implementation) in production code (sonic-net#162)

This is the following step for merging sonic-py-swsssdk into sonic-swss-common sonic-net/sonic-swss-common#387

Note: Test code could still using old python implementation
  • Loading branch information
qiluo-msft authored Nov 6, 2020
1 parent 57e54d9 commit 6b94ec3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import os

from swsssdk import SonicV2Connector
from swsscommon.swsscommon import SonicV2Connector
from swsssdk import SonicDBConfig
from swsssdk import port_util
from swsssdk.port_util import get_index_from_str
Expand Down
13 changes: 11 additions & 2 deletions tests/mock_tables/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
import sys

import mockredis
from swsssdk.interface import redis, DBInterface
import redis
import swsssdk
from swsssdk import SonicV2Connector
from swsssdk import SonicDBConfig
from swsssdk.interface import DBInterface
from swsscommon import swsscommon


if sys.version_info >= (3, 0):
Expand Down Expand Up @@ -91,7 +94,7 @@ def __init__(self, *args, **kwargs):
# to identify the file path to load the db json files.
namespace = kwargs.pop('namespace')
db_name = kwargs.pop('db_name')
self.decode_responses = kwargs.pop('decode_responses') == True
self.decode_responses = kwargs.pop('decode_responses', False) == True
fname = db_name.lower() + ".json"
self.pubsub = MockPubSub()

Expand Down Expand Up @@ -143,3 +146,9 @@ def keys(self, pattern='*'):
mockredis.MockRedis.config_set = config_set
redis.StrictRedis = SwssSyncClient
SonicV2Connector.connect = connect_SonicV2Connector
swsscommon.SonicV2Connector = SonicV2Connector

# pytest case collecting will import some module before monkey patch, so reload
from importlib import reload
import sonic_ax_impl.mibs
reload(sonic_ax_impl.mibs)

0 comments on commit 6b94ec3

Please sign in to comment.