Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test tests #8

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/exengine/kernel/test/test_data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def mock_data_storage():

@pytest.fixture
def data_handler(mock_data_storage, mock_execution_engine):
return DataHandler(mock_data_storage, _executor=mock_execution_engine)
dh = DataHandler(mock_data_storage, _executor=mock_execution_engine)
yield dh
dh.finish()



def test_data_handler_put_and_get(data_handler):
Expand All @@ -68,7 +71,7 @@ def test_data_handler_put_and_get(data_handler):
assert retrieved_metadata == metadata


def test_data_handler_processing_function(data_handler, mock_data_storage):
def test_data_handler_processing_function(mock_data_storage):
"""
Test that DataHandler can process data using a provided processing function, and that
data_handler.get() returns the processed data not the original data.
Expand Down Expand Up @@ -97,6 +100,8 @@ def process_function(coords, image, metadata):
assert np.array_equal(retrieved_image, image * 2)
assert retrieved_metadata == metadata

handler_with_processing.finish()


def test_data_handler_shutdown(data_handler, mock_data_storage):
"""
Expand All @@ -106,6 +111,7 @@ def test_data_handler_shutdown(data_handler, mock_data_storage):
data_handler.await_completion()

assert mock_data_storage.finished

def test_data_handler_with_acquisition_future(data_handler):
"""
Test that DataHandler interacts correctly with AcquisitionFuture.
Expand All @@ -122,4 +128,4 @@ def _notify_data(self, coords, data, metadata, processed, stored):

data_handler.put(coords, image, metadata, future)

assert future.notified
assert future.notified
2 changes: 1 addition & 1 deletion src/exengine/kernel/test/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def test_event_prioritization(execution_engine):
while not event1.executed or not event2.executed or not event3.executed:
time.sleep(0.1)

assert event3.executed_time < event2.executed_time
assert event3.executed_time <= event2.executed_time
assert event1.executed
assert event2.executed
assert event3.executed
Expand Down
Loading