Skip to content

Commit

Permalink
[watermarkstat] Increase UT code coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Nazarii Hnydyn <nazariig@nvidia.com>
  • Loading branch information
nazariig authored and vadymhlushko-mlnx committed Oct 4, 2022
1 parent ce6e785 commit fc3f352
Show file tree
Hide file tree
Showing 4 changed files with 1,276 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/watermarkstat
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ try:
tests_path = os.path.join(modules_path, "tests")
sys.path.insert(0, modules_path)
sys.path.insert(0, tests_path)
import mock_tables.dbconnector
from mock_tables import dbconnector

if os.environ["WATERMARKSTAT_UNIT_TESTING"] == "1":
input_path = os.path.join(tests_path, "wm_input")
mock_db_path = os.path.join(input_path, "mock_db")

for mock_db in os.listdir(mock_db_path):
name, ext = os.path.splitext(mock_db)
if ext == ".json":
dbconnector.dedicated_dbs[name.upper()] = os.path.join(mock_db_path, name)
except KeyError:
pass

Expand Down
13 changes: 13 additions & 0 deletions tests/watermarkstat_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import pytest

import show.main as show
from click.testing import CliRunner
Expand All @@ -13,6 +14,15 @@
sys.path.insert(0, modules_path)


@pytest.fixture(scope="function")
def q_multicast_wm_neg():
print("Setup watermarkstat sample data: no queue multicast watermark counters")
os.environ['WATERMARKSTAT_UNIT_TESTING'] = "1"
yield
del os.environ['WATERMARKSTAT_UNIT_TESTING']
print("Teardown watermarkstat sample data: no queue multicast watermark counters")


class TestWatermarkstat(object):
@classmethod
def setup_class(cls):
Expand All @@ -32,6 +42,9 @@ def test_show_queue_unicast_wm(self):
def test_show_queue_multicast_wm(self):
self.executor(testData['show_q_wm_multicast'])

def test_show_queue_multicast_wm_neg(self, q_multicast_wm_neg):
self.executor(testData['show_q_wm_multicast_neg'])

def test_show_queue_all_wm(self):
self.executor(testData['show_q_wm_all'])

Expand Down
Loading

0 comments on commit fc3f352

Please sign in to comment.