[test] add test for file_handler, ignore ui test in gh action
This commit is contained in:
parent
8a55473222
commit
457301e7c7
10
.github/workflows/python-app.yml
vendored
10
.github/workflows/python-app.yml
vendored
@ -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
|
||||
|
20
nixview/test/test_file_handler.py
Normal file
20
nixview/test/test_file_handler.py
Normal file
@ -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
|
@ -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()
|
||||
|
||||
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
|
||||
assert app._file_open_action.isEnabled()
|
||||
assert app._file_close_action.isEnabled()
|
||||
|
||||
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()
|
Loading…
Reference in New Issue
Block a user