-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
portconfig option to configure Tx power and laser frequency of ZR tra…
…nsceiver module (#2197) (#2330) Cherry-pick of PR #2197 Added new configuration CLI options to configure Tx power and laser frequency of ZR transceiver module
- Loading branch information
Showing
3 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import click | ||
import config.main as config | ||
import operator | ||
import os | ||
import pytest | ||
import sys | ||
|
||
from click.testing import CliRunner | ||
from utilities_common.db import Db | ||
|
||
test_path = os.path.dirname(os.path.abspath(__file__)) | ||
modules_path = os.path.dirname(test_path) | ||
scripts_path = os.path.join(modules_path, "scripts") | ||
sys.path.insert(0, modules_path) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def ctx(scope='module'): | ||
db = Db() | ||
obj = {'config_db':db.cfgdb, 'namespace': ''} | ||
yield obj | ||
|
||
|
||
class TestConfigXcvr(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def test_config_laser_frequency(self, ctx): | ||
#self.basic_check("link-training", ["Ethernet0", "on"], ctx) | ||
result = self.basic_check("frequency", ["Ethernet0", "191300"], ctx) | ||
assert "Setting laser frequency" in result.output | ||
result = self.basic_check("frequency", ["Ethernet0", "--", "-1"], ctx, op=operator.ne) | ||
assert "Error: Frequency must be > 0" in result.output | ||
|
||
def test_config_tx_power(self, ctx): | ||
result = self.basic_check("tx_power", ["Ethernet0", "11.3"], ctx) | ||
assert "Setting target Tx output power" in result.output | ||
result = self.basic_check("tx_power", ["Ethernet0", "11.34"], ctx, op=operator.ne) | ||
assert "Error: tx power must be with single decimal place" in result.output | ||
|
||
def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0): | ||
runner = CliRunner() | ||
result = runner.invoke(config.config.commands["interface"].commands["transceiver"].commands[command_name], para_list, obj = ctx) | ||
print(result.output) | ||
assert op(result.exit_code, expect_result) | ||
return result |