-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 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
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 | ||
) |