Skip to content

Commit

Permalink
Moved mock files to diff dir
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Reddy Karri <[email protected]>
  • Loading branch information
vivekrnv committed Jun 10, 2021
1 parent b92290e commit 6d76514
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 3 additions & 6 deletions tests/dump_tests/module_tests/mock_sonicv2connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

class MockSonicV2Connector():
def __init__(self, dedicated_dbs, namespace=DEFAULT_NAMESPACE):
# TODO: Add Support for
# 1) Different namespace, i.e. asic0, asic1 etc
# 2) In the case when user-provider dedicated_dbs is empty, Read from mock_tables/*_db.json
if namespace != DEFAULT_NAMESPACE:
raise "This Mock doesn't support multi-asic configuration"
self.db = None
Expand All @@ -17,13 +14,13 @@ def __init__(self, dedicated_dbs, namespace=DEFAULT_NAMESPACE):

def connect(self, db_name, retry=False):
if db_name not in self.dedicated_dbs:
return None
raise Exception("{} not found. Available db's: {}".fomrat(db_name, self.dedicated_dbs.keys()))
try:
with open(self.dedicated_dbs[db_name]) as f:
self.db = json.load(f)
self.db_name_connect_to = db_name
except Exception as e:
raise "Connection Failure"
except BaseException as e:
raise "Connection Failure" + str(e)

def get_db_separator(self, db_name):
return self.db_cfg["DATABASES"][db_name]["separator"]
Expand Down
11 changes: 7 additions & 4 deletions tests/dump_tests/module_tests/port_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from dump.helper import create_template_dict, sort_lists
from dump.plugins.port import Port

from .mock_sonicv2connector import MockSonicV2Connector

module_tests_path = os.path.dirname(__file__)
dump_tests_path = os.path.join(module_tests_path, "../")
port_files_path = os.path.join(dump_tests_path,"files","port")
sys.path.append(dump_tests_path)
sys.path.append(module_tests_path)
tests_path = os.path.join(dump_tests_path, "../")
dump_test_input = os.path.join(tests_path,"dump_input")


from module_tests.mock_sonicv2connector import MockSonicV2Connector
# Location for dedicated db's used for UT
port_files_path = os.path.join(dump_test_input,"port")

dedicated_dbs = {}
dedicated_dbs['CONFIG_DB'] = os.path.join(port_files_path, "config_db.json")
Expand Down

0 comments on commit 6d76514

Please sign in to comment.