def test_search_error_500(a_mint, requests_mock): """Internal errors in the mint server might be communicated by plain html instead mint format. This should be handled """ set_mock_response(requests_mock, MINT_SEARCH_STUDY_LEVEL_ERROR_500) with pytest.raises(DICOMTrolleyError) as e: a_mint.find_studies(query=MintQuery(patientName="B*")) assert "Could not parse" in str(e)
def test_wado_datasets_async(a_wado, requests_mock): set_mock_response(requests_mock, WADO_RESPONSE_DICOM) instances = [ MockWadoParameters.as_instance_reference(), MockWadoParameters.as_instance_reference(), ] datasets = [x for x in a_wado.datasets_async(instances)] assert len(datasets) == 2 assert datasets[0].PatientName == "Jane"
def test_wado_get_faulty_dataset(a_wado, requests_mock, mock_response): """Server can return strange invalid dicom-like responses. Catch these""" set_mock_response(requests_mock, mock_response) with pytest.raises(DICOMTrolleyError): a_wado.get_dataset( InstanceReference( study_instance_uid=MockWadoParameters.study_instance_uid, series_instance_uid=MockWadoParameters.series_instance_uid, sop_instance_uid=MockWadoParameters.sop_instance_uid, ))
def test_wado_get_dataset(a_wado, requests_mock): """Retrieve dicom data via a wado call""" set_mock_response(requests_mock, WADO_RESPONSE_DICOM) ds = a_wado.get_dataset( InstanceReference( study_instance_uid=MockWadoParameters.study_instance_uid, series_instance_uid=MockWadoParameters.series_instance_uid, sop_instance_uid=MockWadoParameters.sop_instance_uid, )) assert ds.PatientName == "Jane" assert ds.StudyDescription == "Test"
def test_impax_login_fails(an_impax, requests_mock): set_mock_response(requests_mock, LOGIN_DENIED_IMPAX) with pytest.raises(DICOMTrolleyError): an_impax.log_in("user", "pass")
def test_impax_login_works(an_impax, requests_mock): set_mock_response(requests_mock, LOGIN_SUCCESS_IMPAX) assert an_impax.log_in("user", "pass")
def an_impax(requests_mock): impax = IMPAXDataCenter(wado_url=MockUrls.LOGIN) set_mock_response(requests_mock, LOGIN_IMPAX_INITIAL) return impax