Skip to content

Commit

Permalink
Add our first unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesremuscat committed Jun 10, 2021
1 parent c45a4f5 commit ede26df
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 18 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 4 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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]',
Expand Down
1 change: 0 additions & 1 deletion src/avista/_version.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/avista/devices/blackmagic/atem/commands/mix_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ede26df

Please sign in to comment.