diff options
| author | morefigs <morefigs@gmail.com> | 2019-01-23 16:23:26 +1100 |
|---|---|---|
| committer | morefigs <morefigs@gmail.com> | 2019-01-23 16:23:26 +1100 |
| commit | 76c040e9da5d94dfcb68d3e9a8003b894c1cf1dc (patch) | |
| tree | 525903bc4e2614d40535c7d53a683c869c6c246f | |
| parent | fc9eaae8105a1a4c1ad1a1a98397ba5c74a54983 (diff) | |
| download | pymba-76c040e9da5d94dfcb68d3e9a8003b894c1cf1dc.tar.gz pymba-76c040e9da5d94dfcb68d3e9a8003b894c1cf1dc.zip | |
test file for vimba.py
| -rw-r--r-- | tests/test_vimba.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test_vimba.py b/tests/test_vimba.py new file mode 100644 index 0000000..4da713b --- /dev/null +++ b/tests/test_vimba.py @@ -0,0 +1,44 @@ +import pytest + +from pymba import Vimba, VimbaException + + +def test_version(): + version = Vimba().version.split('.') + assert int(version[0]) >= 1 + assert int(version[1]) >= 7 + assert int(version[2]) >= 0 + + +def test_startup_shutdown(): + with pytest.raises(VimbaException) as e: + Vimba().system().feature_names() + assert e.value.error_code == VimbaException.ERR_STARTUP_NOT_CALLED + + # manual + Vimba().startup() + Vimba().system().feature_names() + Vimba().shutdown() + + # context manager + with Vimba() as vmb: + vmb.system().feature_names() + + +@pytest.fixture +def vmb() -> Vimba: + with Vimba() as v: + yield v + + +# works best with camera(s) attached +def test_interface_camera_ids(vmb: Vimba): + # for ethernet camera discovery + if vmb.system().GeVTLIsPresent: + vmb.system().run_feature_command("GeVDiscoveryAllOnce") + + for func in (vmb.interface_ids, vmb.camera_ids): + ids = func() + assert isinstance(ids, list) + for x in ids: + assert isinstance(x, str) |
