Skip to content

Commit

Permalink
update task tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Jun 5, 2024
1 parent e88eb10 commit f4f1dce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
14 changes: 14 additions & 0 deletions convnwb/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ def ttask():

yield TaskBase()

@pytest.fixture(scope='session')
def ttask_full():
"""Create a test task object."""

task = TaskBase()
task.trial['trial'] = [0, 1, 2]
task.trial['start_time'] = [0, 1, 2]
task.trial['stop_time'] = [1, 2, 3]
task.trial['type'] = ['a', 'b', 'c']
task.trial['field1'] = ['a', 'b', 'c']
task.trial['field2'] = [1, 2, 3]

yield task

@pytest.fixture(scope='session', autouse=True)
def th5file():
"""Save out a test HDF5 file."""
Expand Down
17 changes: 4 additions & 13 deletions convnwb/tests/objects/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,12 @@ def test_task_update_time_apply_type():
assert isinstance(task.position['time'], np.ndarray)
assert np.array_equal(task.position['time'], np.array([15, 25, 35]))

def test_task_to_dict():
def test_task_to_dict(ttask_full):

task = TaskBase()
task.trial['field1'] = ['a', 'b', 'c']
task.trial['field2'] = [1, 2, 3]

odict = task.to_dict()
odict = ttask_full.to_dict()
assert isinstance(odict, dict)

def test_task_to_dataframe():

task = TaskBase()

task.trial['field1'] = ['a', 'b', 'c']
task.trial['field2'] = [1, 2, 3]
def test_task_to_dataframe(ttask_full):

df = task.to_dataframe('trial')
df = ttask_full.to_dataframe('trial')
assert isinstance(df, pd.DataFrame)

0 comments on commit f4f1dce

Please sign in to comment.