mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-04-06 23:53:31 +00:00
major version bump due to dependency change.
now packaged with poetry. added to pypi. major version bump due to dependency change. interface reworked to match the remote-api interface. readme updated with changes to installation pre-commit hook temporarily removed
This commit is contained in:
@@ -1,30 +1,32 @@
|
||||
from dataclasses import dataclass
|
||||
import vbancmd
|
||||
from vbancmd import kinds
|
||||
import random
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
|
||||
import vban_cmd
|
||||
from vban_cmd.kinds import KindId, kinds_all
|
||||
from vban_cmd.kinds import request_kind_map as kindmap
|
||||
|
||||
# let's keep things random
|
||||
kind_id = random.choice(tuple(kind.id for kind in kinds.all))
|
||||
kind_id = random.choice(tuple(kind_id.name.lower() for kind_id in KindId))
|
||||
|
||||
opts = {
|
||||
"ip": "codey.local",
|
||||
"streamname": "codey",
|
||||
"ip": "ws.local",
|
||||
"streamname": "workstation",
|
||||
"port": 6990,
|
||||
"bps": 0,
|
||||
"sync": True,
|
||||
}
|
||||
|
||||
vbans = {kind.id: vbancmd.connect(kind_id, **opts) for kind in kinds.all}
|
||||
vbans = {kind.name: vban_cmd.api(kind.name, **opts) for kind in kinds_all}
|
||||
tests = vbans[kind_id]
|
||||
kind = kinds.get(kind_id)
|
||||
kind = kindmap(kind_id)
|
||||
|
||||
|
||||
@dataclass
|
||||
class Data:
|
||||
"""bounds data to map tests to a kind"""
|
||||
|
||||
name: str = kind.id
|
||||
name: str = kind.name
|
||||
phys_in: int = kind.ins[0] - 1
|
||||
virt_in: int = kind.ins[0] + kind.ins[1] - 1
|
||||
phys_out: int = kind.outs[0] - 1
|
||||
@@ -41,7 +43,6 @@ data = Data()
|
||||
def setup_module():
|
||||
print(f"\nRunning tests for kind [{data.name}]\n", file=sys.stdout)
|
||||
tests.login()
|
||||
tests.apply_profile("blank")
|
||||
|
||||
|
||||
def teardown_module():
|
||||
|
||||
7
tests/conftest.py
Normal file
7
tests/conftest.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--run-slow",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Run slow tests",
|
||||
)
|
||||
@@ -1,31 +0,0 @@
|
||||
Function RunTests {
|
||||
$coverage = "./tests/pytest_coverage.log"
|
||||
$run_tests = "pytest -v --capture=tee-sys --junitxml=./tests/.coverage.xml"
|
||||
$match_pattern = "^=|^\s*$|^Running|^Using|^plugins|^collecting|^tests"
|
||||
|
||||
if ( Test-Path $coverage ) { Clear-Content $coverage }
|
||||
|
||||
ForEach ($line in $(Invoke-Expression $run_tests)) {
|
||||
If ( $line -Match $match_pattern ) {
|
||||
if ( $line -Match "^Running tests for kind \[(\w+)\]" ) { $kind = $Matches[1] }
|
||||
$line | Tee-Object -FilePath $coverage -Append
|
||||
}
|
||||
}
|
||||
Write-Output "$(Get-TimeStamp)" | Out-file $coverage -Append
|
||||
|
||||
Invoke-Expression "genbadge tests -t 90 -i ./tests/.coverage.xml -o ./tests/$kind.svg"
|
||||
}
|
||||
|
||||
Function Get-TimeStamp {
|
||||
|
||||
return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
|
||||
|
||||
}
|
||||
|
||||
if ($MyInvocation.InvocationName -ne ".") {
|
||||
Invoke-Expression ".\venv\Scripts\Activate.ps1"
|
||||
|
||||
RunTests
|
||||
|
||||
Invoke-Expression "deactivate"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from tests import tests, data
|
||||
|
||||
from tests import data, tests
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value", [False, True])
|
||||
@@ -12,15 +13,27 @@ class TestSetAndGetBoolHigher:
|
||||
"index,param",
|
||||
[
|
||||
(data.phys_in, "mute"),
|
||||
(data.phys_in, "mono"),
|
||||
(data.virt_in, "mc"),
|
||||
(data.virt_in, "mono"),
|
||||
(data.virt_in, "solo"),
|
||||
],
|
||||
)
|
||||
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
|
||||
setattr(tests.strip[index], param, value)
|
||||
assert getattr(tests.strip[index], param) == value
|
||||
|
||||
@pytest.mark.skipif(
|
||||
data.name == "banana",
|
||||
reason="Only test if logged into Basic or Potato version",
|
||||
)
|
||||
@pytest.mark.parametrize(
|
||||
"index,param",
|
||||
[
|
||||
(data.phys_in, "mc"),
|
||||
],
|
||||
)
|
||||
def test_it_sets_and_gets_strip_bool_params_mc(self, index, param, value):
|
||||
setattr(tests.strip[index], param, value)
|
||||
assert getattr(tests.strip[index], param) == value
|
||||
|
||||
""" bus tests, physical and virtual """
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from tests import tests, data
|
||||
from vbancmd import kinds
|
||||
import re
|
||||
from vban_cmd import kinds
|
||||
|
||||
from tests import data, tests
|
||||
|
||||
|
||||
class TestPublicPacketLower:
|
||||
@@ -10,9 +12,15 @@ class TestPublicPacketLower:
|
||||
"""Tests for a valid rt data packet"""
|
||||
|
||||
def test_it_gets_an_rt_data_packet(self):
|
||||
assert tests.public_packet.voicemeetertype in (kind.id for kind in kinds.all)
|
||||
assert tests.public_packet.voicemeetertype in (
|
||||
kind.name for kind in kinds.kinds_all
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
"not config.getoption('--run-slow')",
|
||||
reason="Only run when --run-slow is given",
|
||||
)
|
||||
@pytest.mark.parametrize("value", [0, 1])
|
||||
class TestSetRT:
|
||||
__test__ = True
|
||||
@@ -26,7 +34,8 @@ class TestSetRT:
|
||||
("bus", data.virt_out, "mono"),
|
||||
],
|
||||
)
|
||||
def test_it_gets_an_rt_data_packet(self, kls, index, param, value):
|
||||
tests.set_rt(f"{kls}[{index}]", param, value)
|
||||
def test_it_sends_a_text_request(self, kls, index, param, value):
|
||||
tests._set_rt(f"{kls}[{index}]", param, value)
|
||||
time.sleep(0.1)
|
||||
target = getattr(tests, kls)[index]
|
||||
assert getattr(target, param) == bool(value)
|
||||
|
||||
Reference in New Issue
Block a user