def test_send_cfind_no_connection(a_mock_ae_associate, monkeypatch): a_mock_ae_associate.is_established = False monkeypatch.setattr( "dicomtrolley.dicom_qr.AE.associate", Mock(return_value=a_mock_ae_associate), ) qr = DICOMQR(host="host", port=123) with pytest.raises(DICOMTrolleyError): qr.send_c_find(query=DICOMQuery())
def test_send_cfind(a_mock_ae_associate, monkeypatch): monkeypatch.setattr( "dicomtrolley.dicom_qr.AE.associate", Mock(return_value=a_mock_ae_associate), ) qr = DICOMQR(host="host", port=123) results = qr.send_c_find(query=DICOMQuery()) assert len(results) == 2 assert results[0].PatientName == "patient"
def test_find_studies(monkeypatch): qr = DICOMQR(host="host", port=123) qr.send_c_find = Mock( return_value=create_c_find_image_response( study_instance_uid="Study1", series_instance_uids=["Series1"], sop_class_uids=[f"Instance{i}" for i in range(1, 10)], ) ) studies = qr.find_studies(query=None) assert len(studies) == 1 assert studies[0].uid == "Study1" assert len(studies[0].series[0].instances) == 9