From 76c040e9da5d94dfcb68d3e9a8003b894c1cf1dc Mon Sep 17 00:00:00 2001 From: morefigs Date: Wed, 23 Jan 2019 16:23:26 +1100 Subject: test file for vimba.py --- tests/test_vimba.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/test_vimba.py 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) -- cgit v1.2.3