-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage fixes, refactoring, code style
- Loading branch information
Showing
13 changed files
with
86 additions
and
16 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 |
---|---|---|
|
@@ -5,4 +5,7 @@ venv | |
*.env.test.* | ||
.pytest_cache | ||
storage | ||
dist | ||
dist | ||
#pytest-cov | ||
.coverage | ||
coverage.xml |
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
File renamed without changes.
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,4 +1,5 @@ | ||
-r extended.txt | ||
pytest~=7.4.3 | ||
pytest-asyncio>=0.21.0 | ||
pytest-mock~=3.12.0 | ||
pytest-mock~=3.12.0 | ||
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
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,29 @@ | ||
import microcore as mc | ||
|
||
|
||
def test_storage_read_write(): | ||
mc.storage.clean('tests_tmp') | ||
filename = mc.storage.write("tests_tmp/test_file", "test content") | ||
content = mc.storage.read(filename) | ||
assert content == "test content" | ||
mc.storage.clean('tests_tmp') | ||
|
||
|
||
|
||
def test_storage_write_existing(): | ||
mc.storage.clean('tests_tmp') | ||
filename = mc.storage.write("tests_tmp/test_b", "old content") | ||
filename2 = mc.storage.write("tests_tmp/test_b", "new content") | ||
assert mc.storage.read(filename) == "old content" | ||
assert mc.storage.read(filename2) == "new content" | ||
assert filename != filename2 | ||
mc.storage.clean('tests_tmp') | ||
|
||
|
||
def test_storage_clean(): | ||
|
||
mc.storage.clean("tests_tmp") | ||
filename = mc.storage.write("tests_tmp/file", "") | ||
assert (mc.storage.storage_path / filename).exists() | ||
mc.storage.clean("tests_tmp") | ||
assert not (mc.storage.storage_path / filename).exists() |
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,33 @@ | ||
from unittest.mock import patch | ||
from microcore.ui import info, debug, error, ask_yn | ||
|
||
|
||
def test_info(): | ||
with patch("builtins.print") as mock_print: | ||
info("Test message") | ||
args, _ = mock_print.call_args | ||
assert "Test message" in args[0] | ||
|
||
|
||
def test_debug(): | ||
with patch("builtins.print") as mock_print: | ||
debug("Debug message") | ||
args, _ = mock_print.call_args | ||
assert "Debug message" in args[0] | ||
|
||
|
||
def test_error(): | ||
with patch("builtins.print") as mock_print: | ||
error("Error message") | ||
args, _ = mock_print.call_args | ||
assert "Error message" in args[0] | ||
|
||
|
||
def test_ask_yn_yes(): | ||
with patch("builtins.input", return_value="y"): | ||
assert ask_yn("Confirm?") is True | ||
|
||
|
||
def test_ask_yn_no(): | ||
with patch("builtins.input", return_value="n"): | ||
assert ask_yn("Confirm?") is False |