now calling command.reset() before each test run

factory unit tests added

--run-slow flag added to pre-commit. (ensure all tests are run)
This commit is contained in:
onyx-and-iris
2022-07-16 21:54:41 +01:00
parent 1f522b997e
commit 08eff6da91
5 changed files with 48 additions and 5 deletions

View File

@@ -43,6 +43,7 @@ data = Data()
def setup_module():
print(f"\nRunning tests for kind [{data.name}]\n", file=sys.stdout)
tests.login()
tests.command.reset()
def teardown_module():

View File

@@ -1,6 +1,6 @@
Function RunTests {
$coverage = "./tests/pytest_coverage.log"
$run_tests = "pytest -v --capture=tee-sys --junitxml=./tests/.coverage.xml"
$run_tests = "pytest --run-slow -v --capture=tee-sys --junitxml=./tests/.coverage.xml"
$match_pattern = "^=|^\s*$|^Running|^Using|^plugins|^collecting|^tests"
if ( Test-Path $coverage ) { Clear-Content $coverage }

43
tests/test_factory.py Normal file
View File

@@ -0,0 +1,43 @@
import pytest
from tests import data, tests
class TestRemoteFactories:
__test__ = True
@pytest.mark.skipif(
data.name != "basic",
reason="Skip test if kind is not basic",
)
def test_it_tests_remote_attrs_for_basic(self):
assert hasattr(tests, "strip")
assert hasattr(tests, "bus")
assert hasattr(tests, "command")
assert len(tests.strip) == 3
assert len(tests.bus) == 2
@pytest.mark.skipif(
data.name != "banana",
reason="Skip test if kind is not basic",
)
def test_it_tests_remote_attrs_for_banana(self):
assert hasattr(tests, "strip")
assert hasattr(tests, "bus")
assert hasattr(tests, "command")
assert len(tests.strip) == 5
assert len(tests.bus) == 5
@pytest.mark.skipif(
data.name != "potato",
reason="Skip test if kind is not basic",
)
def test_it_tests_remote_attrs_for_potato(self):
assert hasattr(tests, "strip")
assert hasattr(tests, "bus")
assert hasattr(tests, "command")
assert len(tests.strip) == 8
assert len(tests.bus) == 8

View File

@@ -36,6 +36,6 @@ class TestSetRT:
)
def test_it_sends_a_text_request(self, kls, index, param, value):
tests._set_rt(f"{kls}[{index}]", param, value)
time.sleep(0.1)
time.sleep(0.02)
target = getattr(tests, kls)[index]
assert getattr(target, param) == bool(value)