def test_read_missing_id(self, mock_get_db_connection): """Raises an error when the id was not provided at init""" r = Resource(resource='test') with pytest.raises(OperationOutcome, match='Resource ID is required'): r = r.read() assert mock_get_db_connection.return_value.read.call_count == 0
def test_read(self, mock_get_db_connection): """Calls the read method of the fhirbase client and registers the resource """ test_id = {'id': 'id'} read_ret_data = {'my': 'resource', **test_id} mock_get_db_connection.return_value.read.return_value = read_ret_data r = Resource(id=test_id) r = r.read() mock_get_db_connection.return_value.read.assert_called_once_with({ 'resourceType': 'Resource', 'id': r.id }) assert r.resource == read_ret_data