From 457301e7c765eac1667137b3a5b271bc13d60a71 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Sat, 6 Feb 2021 16:38:45 +0100 Subject: [PATCH] [test] add test for file_handler, ignore ui test in gh action --- .github/workflows/python-app.yml | 10 +------- nixview/test/test_file_handler.py | 20 ++++++++++++++++ nixview/test/{test_main.py => test_ui.py} | 28 +++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 nixview/test/test_file_handler.py rename nixview/test/{test_main.py => test_ui.py} (60%) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 0551925..e6a191d 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -20,14 +20,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.6 - - name: setup - env: - DISPLAY: ':99.0' - run: | - sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 - sudo apt install libxcb-xinerama0 libxcb-xfixes0 - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX - - name: Install dependencies run: | python -m pip install --upgrade pip @@ -41,4 +33,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pytest + pytest --ignore nixview/test/test_ui.py diff --git a/nixview/test/test_file_handler.py b/nixview/test/test_file_handler.py new file mode 100644 index 0000000..255e7ae --- /dev/null +++ b/nixview/test/test_file_handler.py @@ -0,0 +1,20 @@ +import pytest +import os +from nixview.util import file_handler + +test_file = os.path.join(".", "nix_test.h5") + +@pytest.fixture +def setup(): + if not os.path.exists(test_file): + from nixview.test.create_test_file import create_test_file + create_test_file() + fhandler = file_handler.FileHandler() + yield fhandler + fhandler.close() + +def test_file_handler(setup): + assert not setup.is_valid + setup.open(test_file) + + assert setup.is_valid \ No newline at end of file diff --git a/nixview/test/test_main.py b/nixview/test/test_ui.py similarity index 60% rename from nixview/test/test_main.py rename to nixview/test/test_ui.py index 158b17f..73323ce 100644 --- a/nixview/test/test_main.py +++ b/nixview/test/test_ui.py @@ -12,20 +12,24 @@ def app(qtbot): create_test_file() test_nv = NixView() qtbot.addWidget(test_nv) - - return test_nv - + yield test_nv + test_nv._file_close_action.trigger() + def test_file_open(app, qtbot): + assert app._help_action.isEnabled() + assert app._about_action.isEnabled() + assert app._quit_action.isEnabled() + assert not app._table_action.isEnabled() + assert not app._plot_action.isEnabled() + assert not app._file_handler.is_valid - + app.open_file(test_file) assert app._file_handler.is_valid - assert app._help_action.isEnabled() + assert app._file_open_action.isEnabled() + assert app._file_close_action.isEnabled() -def test_file_handler(app): - assert app._file_handler.is_valid - assert not app._plot_action.isEnabled() - assert not app._table_action.isEnabled() - assert app._file_handler._entity_buffer is not None - assert app._file_handler.file_descriptor is not None - \ No newline at end of file + app._file_close_action.trigger() + assert not app._file_handler.is_valid + assert app._file_open_action.isEnabled() + assert not app._file_close_action.isEnabled()