-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests and code improvements (#377)
- Loading branch information
1 parent
8690971
commit c7b5e8e
Showing
12 changed files
with
630 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[run] | ||
source = asusrouter | ||
omit = | ||
# Constants modules | ||
asusrouter/modules/endpoint/devicemap_const.py |
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Pytest for running tests | ||
pytest>=7.4.3 | ||
pytest-asyncio>=0.21.1 | ||
pytest-cov>=4.1.0 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
"""Tests for AsusRouter""" | ||
"""Tests for AsusRouter.""" |
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 @@ | ||
"""Tests for the AsusRouter modules.""" |
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 @@ | ||
"""Tests for AsusRouter endpoint module.""" |
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,27 @@ | ||
"""Test AsusRouter command endpoint module.""" | ||
|
||
from unittest.mock import patch | ||
|
||
from asusrouter.modules.endpoint import command | ||
|
||
|
||
def test_read(): | ||
"""Test read function.""" | ||
|
||
# Test data | ||
content = '{"key1": "value1", "key2": "value2"}' | ||
expected_command = {"key1": "value1", "key2": "value2"} | ||
|
||
# Mock the read_json_content function | ||
with patch( | ||
"asusrouter.modules.endpoint.command.read_json_content", | ||
return_value=expected_command, | ||
) as mock_read_json_content: | ||
# Call the function | ||
result = command.read(content) | ||
|
||
# Check the result | ||
assert result == expected_command | ||
|
||
# Check that read_json_content was called with the correct argument | ||
mock_read_json_content.assert_called_once_with(content) |
Oops, something went wrong.