Skip to content

Commit

Permalink
added pytest for ports
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Aug 24, 2024
1 parent f5de746 commit 0cda04c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ python_files =
*_test.py
tests.py
addopts =
--cov=napalm
--cov-report term-missing
# --cov=napalm
# --cov-report term-missing
-vs
; --pylama
json_report = report.json
Expand Down
34 changes: 34 additions & 0 deletions test/unit/jsonrpc_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Determines the JSON-RPC port to use based on the provided configuration.
Args:
config (dict): A dictionary containing the configuration options.
Returns:
int: The JSON-RPC port to use.
"""

import pytest

from napalm_srlinux.srlinux import NokiaSRLinuxDriver


@pytest.fixture
def driver():
return NokiaSRLinuxDriver("hostname", "username", "password")


def test_determine_jsonrpc_port(driver):
# Test default case
assert driver._determine_jsonrpc_port({}) == 443

# Test when jsonrpc_port is specified
assert driver._determine_jsonrpc_port({"jsonrpc_port": 8080}) == 8080

# Test when insecure is set and jsonrpc_port is not specified
assert driver._determine_jsonrpc_port({"insecure": True}) == 80

# Test when both jsonrpc_port and insecure are set
assert (
driver._determine_jsonrpc_port({"jsonrpc_port": 9000, "insecure": True}) == 9000
)

0 comments on commit 0cda04c

Please sign in to comment.