|
1 | 1 | import os
|
2 | 2 | import sys
|
3 | 3 | import pfc.main as pfc
|
4 |
| -from pfc_input.assert_show_output import pfc_cannot_find_intf, pfc_show_asymmetric_all, \ |
| 4 | +from .pfc_input.assert_show_output import pfc_cannot_find_intf, pfc_show_asymmetric_all, \ |
5 | 5 | pfc_show_asymmetric_intf, pfc_show_priority_all, pfc_show_priority_intf, \
|
6 |
| - pfc_config_asymmetric, pfc_config_priority_on, pfc_asym_cannot_find_intf |
| 6 | + pfc_config_priority_on, pfc_asym_cannot_find_intf |
7 | 7 | from utilities_common.db import Db
|
8 | 8 |
|
9 | 9 | from click.testing import CliRunner
|
|
18 | 18 |
|
19 | 19 | class TestPfcBase(object):
|
20 | 20 |
|
21 |
| - @classmethod |
22 |
| - def setup_class(cls): |
23 |
| - print("SETUP") |
24 |
| - os.environ["PATH"] += os.pathsep + scripts_path |
25 |
| - os.environ['UTILITIES_UNIT_TESTING'] = "2" |
26 |
| - |
27 |
| - def executor(self, cliobj, command, expected_rc=0, expected_output=None, runner=CliRunner()): |
| 21 | + def executor(self, cliobj, command, expected_rc=0, expected_output=None, expected_cfgdb_entry=None, runner=CliRunner()): |
28 | 22 | db = Db()
|
29 | 23 | result = runner.invoke(cliobj, command, obj=db)
|
30 | 24 | print(result.exit_code)
|
31 | 25 | print(result.output)
|
32 | 26 |
|
33 | 27 | if result.exit_code != expected_rc:
|
34 | 28 | print(result.exception)
|
35 |
| - |
36 | 29 | assert result.exit_code == expected_rc
|
| 30 | + |
37 | 31 | if expected_output:
|
38 | 32 | assert result.output == expected_output
|
39 | 33 |
|
40 |
| - @classmethod |
41 |
| - def teardown_class(cls): |
42 |
| - os.environ["PATH"] = os.pathsep.join(os.environ["PATH"].split(os.pathsep)[:-1]) |
43 |
| - os.environ["UTILITIES_UNIT_TESTING"] = "0" |
44 |
| - print("TEARDOWN") |
| 34 | + if expected_cfgdb_entry: |
| 35 | + (table, key, field, expected_val) = expected_cfgdb_entry |
| 36 | + configdb = db.cfgdb |
| 37 | + entry = configdb.get_entry(table, key) |
| 38 | + assert entry.get(field) == expected_val |
45 | 39 |
|
46 | 40 |
|
47 | 41 | class TestPfc(TestPfcBase):
|
48 | 42 |
|
49 | 43 | @classmethod
|
50 | 44 | def setup_class(cls):
|
51 |
| - super().setup_class() |
52 | 45 | from mock_tables import dbconnector
|
53 | 46 | from mock_tables import mock_single_asic
|
54 | 47 | reload(mock_single_asic)
|
@@ -80,7 +73,7 @@ def test_pfc_show_priority_intf_fake(self):
|
80 | 73 |
|
81 | 74 | def test_pfc_config_asymmetric(self):
|
82 | 75 | self.executor(pfc.cli, ['config', 'asymmetric', 'on', 'Ethernet0'],
|
83 |
| - expected_output=pfc_config_asymmetric) |
| 76 | + expected_cfgdb_entry=('PORT', 'Ethernet0', 'pfc_asym', 'on')) |
84 | 77 |
|
85 | 78 | def test_pfc_config_priority(self):
|
86 | 79 | self.executor(pfc.cli, ['config', 'priority', 'on', 'Ethernet0', '5'],
|
|
0 commit comments