Skip to content

Commit

Permalink
Merge pull request #142 from jpgill86/automate-tests
Browse files Browse the repository at this point in the history
Run automated test suite with GitHub Actions
  • Loading branch information
jpgill86 committed Jan 23, 2021
2 parents 768c491 + 3f1dc97 commit 01a6d0b
Show file tree
Hide file tree
Showing 19 changed files with 225 additions and 112 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ jobs:
strategy:
matrix:
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9']
env:
DISPLAY: ':99.0'
XDG_RUNTIME_DIR: /tmp/runtime-runner
steps:
- name: Set up virtual framebuffer (xvfb) for Qt GUI testing
# https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html#github-actions
run: |
sudo apt-get install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 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: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -42,22 +51,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install package from repository
run: |
pip install -e .
- name: Install other required dependencies
- name: Install package from repository with test dependencies
run: |
pip install PyQt5
pip install -e .[tests]
- name: List pip packages
run: |
pip -V
pip list
- name: Test imports
- name: Run tests
run: |
python -c "import ephyviewer"
python -c "import ephyviewer.datasource"
python -c "import ephyviewer.icons"
python -c "import ephyviewer.tests"
nosetests
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ doc/_build/*
build/*
dist/*
ephyviewer.egg-info/*
ephyviewer/tests/*.avi
examples/*.avi
examples/*.csv
*.avi
*.csv
/.idea
/venv
13 changes: 9 additions & 4 deletions ephyviewer/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@



def test_base():
def test_base(interactive=False):
app = ephyviewer.mkQApp()
win = ephyviewer.base.ViewerBase()
win.show()
app.exec_()

if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()




if __name__=='__main__':
test_base()
test_base(interactive=True)
13 changes: 8 additions & 5 deletions ephyviewer/tests/test_dataframeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@



def test_dataframe_view():
def test_dataframe_view(interactive=False):


df = pd.DataFrame()
Expand All @@ -20,11 +20,14 @@ def test_dataframe_view():

win = ephyviewer.MainViewer(debug=True)
win.add_view(view)
win.show()

app.exec_()

if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()


if __name__=='__main__':
test_dataframe_view()
test_dataframe_view(interactive=True)
18 changes: 9 additions & 9 deletions ephyviewer/tests/test_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import os

from ephyviewer.tests.testing_tools import make_video_file
from ephyviewer.tests.testing_tools import make_video_file, get_tdt_test_files


def test_InMemoryAnalogSignalSource():
Expand Down Expand Up @@ -94,10 +94,10 @@ def test_spikesource():


def test_neo_rawio_sources():
#TODO make autorun neo tdtrawio test before
from neo.rawio.tdtrawio import TdtRawIO

dirname = '/tmp/files_for_testing_neo/tdt/aep_05/'
local_test_dir = get_tdt_test_files()
dirname = os.path.join(local_test_dir, 'aep_05')
neorawio = TdtRawIO(dirname=dirname)
neorawio.parse_header()
print(neorawio)
Expand Down Expand Up @@ -151,10 +151,10 @@ def test_neo_object_sources():


if __name__=='__main__':
#~ test_InMemoryAnalogSignalSource()
#~ test_VideoMultiFileSource()
#~ test_InMemoryEventSource()
#~ test_InMemoryEpochSource()
#~ test_spikesource()
#~ test_neo_rawio_sources()
test_InMemoryAnalogSignalSource()
test_VideoMultiFileSource()
test_InMemoryEventSource()
test_InMemoryEpochSource()
test_spikesource()
test_neo_rawio_sources()
test_neo_object_sources()
37 changes: 25 additions & 12 deletions ephyviewer/tests/test_epochencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ephyviewer.datasource.epochs import WritableEpochSource


def test_EpochEncoder():
def test_EpochEncoder(interactive=False):
possible_labels = ['AAA', 'BBB', 'CCC', 'DDD']

ep_times = np.arange(0, 10., .5)
Expand All @@ -18,12 +18,16 @@ def test_EpochEncoder():

win = ephyviewer.MainViewer(show_step=False, show_global_xsize=True, debug=False)
win.add_view(view)
win.show()

app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()


def test_EpochEncoder_settings():
def test_EpochEncoder_settings(interactive=False):
possible_labels = ['AAA', 'BBB', 'CCC', 'DDD']

ep_times = np.arange(0, 10., .5)
Expand All @@ -38,12 +42,16 @@ def test_EpochEncoder_settings():

win = ephyviewer.MainViewer(show_step=True, show_global_xsize=True, debug=False, settings_name='epoch_encode_test1', )
win.add_view(view)
win.show()

app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()


def test_EpochEncoder_empty():
def test_EpochEncoder_empty(interactive=False):
possible_labels = ['AAA', 'BBB', 'CCC', 'DDD']

source = WritableEpochSource(epoch=None, possible_labels=possible_labels)
Expand All @@ -54,11 +62,16 @@ def test_EpochEncoder_empty():

win = ephyviewer.MainViewer(show_step=False, show_global_xsize=True, debug=False)
win.add_view(view)
win.show()

app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()


if __name__=='__main__':
test_EpochEncoder()
#~ test_EpochEncoder_settings()
test_EpochEncoder_empty()
test_EpochEncoder(interactive=True)
test_EpochEncoder_settings(interactive=True)
test_EpochEncoder_empty(interactive=True)
12 changes: 8 additions & 4 deletions ephyviewer/tests/test_epochviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ephyviewer.tests.testing_tools import make_fake_epoch_source


def test_epoch_viewer():
def test_epoch_viewer(interactive=False):
source = make_fake_epoch_source()


Expand All @@ -13,10 +13,14 @@ def test_epoch_viewer():

win = ephyviewer.MainViewer(debug=True)
win.add_view(view)
win.show()

app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()


if __name__=='__main__':
test_epoch_viewer()
test_epoch_viewer(interactive=True)
12 changes: 8 additions & 4 deletions ephyviewer/tests/test_eventlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ephyviewer.tests.testing_tools import make_fake_event_source


def test_eventlist():
def test_eventlist(interactive=False):
source = make_fake_event_source()


Expand All @@ -13,11 +13,15 @@ def test_eventlist():

win = ephyviewer.MainViewer(debug=True)
win.add_view(view)
win.show()

app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()



if __name__=='__main__':
test_eventlist()
test_eventlist(interactive=True)
37 changes: 26 additions & 11 deletions ephyviewer/tests/test_mainviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@



def test_mainviewer():
def test_mainviewer(interactive=False):

class FakeView(ViewerBase):
def __init__(self, name=''):
ViewerBase.__init__(self, name)
self.v = None
def refresh(self):
self.v = self.t
#~ print('refresh', self.name, self.t)
Expand All @@ -35,10 +38,14 @@ def get_settings(self):
win.add_view(view4, split_with='view1', orientation='horizontal')
win.add_view(view5, location='bottom', orientation='horizontal')

win.show()
app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()

def test_mainviewer2():
def test_mainviewer2(interactive=False):
from ephyviewer.tests.testing_tools import make_fake_video_source
from ephyviewer.tests.testing_tools import make_fake_signals
from ephyviewer.tests.testing_tools import make_fake_event_source
Expand All @@ -63,11 +70,15 @@ def test_mainviewer2():
win.add_view(view4)
win.add_view(view3, location='bottom', orientation='horizontal')

win.show()
app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()


def test_save_load_params():
def test_save_load_params(interactive=False):
from ephyviewer.tests.testing_tools import make_fake_signals


Expand All @@ -81,12 +92,16 @@ def test_save_load_params():
#TODO bug because new params!!!!!!!
win.add_view(view1)

win.show()
app.exec_()
if interactive:
win.show()
app.exec_()
else:
# close thread properly
win.close()



if __name__=='__main__':
#~ test_mainviewer()
test_mainviewer()
test_mainviewer2()
#~ test_save_load_params()
test_save_load_params(interactive=True)
12 changes: 8 additions & 4 deletions ephyviewer/tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@



def test_base():
def test_navigation(interactive=False):
app = ephyviewer.mkQApp()
toolbar = ephyviewer.NavigationToolBar()
toolbar.show()
app.exec_()

if interactive:
toolbar.show()
app.exec_()
else:
# close thread properly
toolbar.close()


if __name__=='__main__':
test_base()
test_navigation(interactive=True)

0 comments on commit 01a6d0b

Please sign in to comment.