diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..10149e1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Test avista + +on: + - push + - pull_request + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions + - name: Test with tox + run: tox diff --git a/setup.py b/setup.py index 8cf3f86..3947c25 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,20 @@ -from setuptools import setup, find_packages +from setuptools import setup, find_namespace_packages import re -VERSIONFILE = "src/avista/_version.py" -verstr = "unknown" -try: - verstrline = open(VERSIONFILE, "rt").read() - VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]" - mo = re.search(VSRE, verstrline, re.M) - if mo: - verstr = mo.group(1) -except EnvironmentError: - print("unable to find version in %s" % (VERSIONFILE,)) - raise RuntimeError("if %s exists, it is required to be well-formed" % (VERSIONFILE,)) - setup( name='avista', - version=verstr, + use_scm_version=True, description='Library for controlling A/V devices', author='James Muscat', author_email='jamesremuscat@gmail.com', url='https://github.com/jamesremuscat/avista', - packages=find_packages('src', exclude=["*.tests"]), + packages=find_namespace_packages('src', exclude=["*.tests"]), package_dir={'': 'src'}, long_description="""\ avista is a library for controlling A/V devices such as video switchers. It is a modernised rewrite of the avx library from the same author. """, - setup_requires=[], + setup_requires=['setuptools_scm'], tests_require=[], install_requires=[ 'autobahn[twisted]', diff --git a/src/avista/_version.py b/src/avista/_version.py deleted file mode 100644 index b8023d8..0000000 --- a/src/avista/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '0.0.1' diff --git a/src/avista/devices/blackmagic/atem/commands/mix_effects.py b/src/avista/devices/blackmagic/atem/commands/mix_effects.py index f532e85..34ccf9e 100644 --- a/src/avista/devices/blackmagic/atem/commands/mix_effects.py +++ b/src/avista/devices/blackmagic/atem/commands/mix_effects.py @@ -483,7 +483,7 @@ def calculate(cls, obj): 'index' / Int8ub, 'key_index' / Int8ub, 'type' / EnumAdapter(KeyType)(Default(Int8ub, 0)), - 'fly_enabled' / Flag, + 'fly_enabled' / Default(Flag, False), Padding(3) ) diff --git a/src/avista/devices/blackmagic/atem/commands/tests/__init__.py b/src/avista/devices/blackmagic/atem/commands/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/avista/devices/blackmagic/atem/commands/tests/test_mix_effects.py b/src/avista/devices/blackmagic/atem/commands/tests/test_mix_effects.py new file mode 100644 index 0000000..0fd9335 --- /dev/null +++ b/src/avista/devices/blackmagic/atem/commands/tests/test_mix_effects.py @@ -0,0 +1,10 @@ +from avista.devices.blackmagic.atem.commands.mix_effects import SetKeyerType +from avista.devices.blackmagic.atem.constants import KeyType + + +def test_set_keyer_type(): + cmd = SetKeyerType(index=0, key_index=1, type=KeyType.PATTERN) + b = cmd.to_bytes() + + assert b[0:4] == b'CKTp' + assert b[4] == 0x80 # = binary 10000000 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c89c72c --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +# tox (https://tox.readthedocs.io/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py38 + +[testenv] +deps = + pytest + autobahn[twisted] + construct +commands = + pytest --import-mode=importlib + +[gh-actions] +python = + 3.8: py38