tests: removed time_db tests from aaredb as have standardised this wrapper
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import io
|
||||
import json
|
||||
from unittest.mock import MagicMock, patch, ANY
|
||||
from aare.daq.aaredb import AareWrapper, time_db_call
|
||||
from aare.common.beamline import MXBeamline
|
||||
from unittest.mock import MagicMock, patch
|
||||
from aare.daq.aaredb import AareWrapper
|
||||
from aare.common.models import (
|
||||
SampleShortInfo, PuckLoadedInfo, DewarAddress,
|
||||
DAQStatusModel, ScanResultPayloadModel
|
||||
SampleShortInfo, PuckLoadedInfo, DewarAddress
|
||||
)
|
||||
from aare.common.raster_grid import RasterGridRequest, CenterOfMassModel
|
||||
from aare.common.rotation_scan import RotationScanRequest
|
||||
@@ -67,36 +63,6 @@ def geom_model():
|
||||
beam_size_mm=Coordinate(x=0.01, y=0.01)
|
||||
)
|
||||
|
||||
def test_time_db_call_decorator_logs_duration(caplog):
|
||||
import logging
|
||||
caplog.set_level(logging.DEBUG)
|
||||
|
||||
@time_db_call
|
||||
def slow_func():
|
||||
import time
|
||||
time.sleep(0.01)
|
||||
return "done"
|
||||
|
||||
result = slow_func()
|
||||
assert result == "done"
|
||||
assert "Starting AareDB call: slow_func" in caplog.text
|
||||
assert "Finished AareDB call: slow_func in" in caplog.text
|
||||
|
||||
def test_time_db_call_decorator_logs_failure(caplog):
|
||||
import logging
|
||||
caplog.set_level(logging.DEBUG)
|
||||
|
||||
@time_db_call
|
||||
def fail_func():
|
||||
raise ValueError("oops")
|
||||
|
||||
with pytest.raises(ValueError, match="oops"):
|
||||
fail_func()
|
||||
|
||||
assert "Starting AareDB call: fail_func" in caplog.text
|
||||
assert "fail_func FAILED after" in caplog.text
|
||||
assert "with error: oops" in caplog.text
|
||||
|
||||
@patch("aareDB.ApiClient")
|
||||
@patch("aareDB.TellsRunnerApi")
|
||||
@patch("aareDB.SamplesRunnerApi")
|
||||
|
||||
Reference in New Issue
Block a user