[test] add test for file_handler, ignore ui test in gh action
This commit is contained in:
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()
|
||||
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
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user