def test_search_did__with_percent_wildcard__wildcard_disabled__should_raise_exception( mocker, rucio): rucio.instance_config['wildcard_enabled'] = False mocker.patch.object(rucio, 'search_did', return_value=[{ 'scope': 'scope', 'name': 'name1', 'bytes': None, 'did_type': 'CONTAINER' }, { 'scope': 'scope', 'name': 'name2', 'bytes': None, 'did_type': 'DATASET' }, { 'scope': 'scope', 'name': 'name3', 'bytes': 123, 'did_type': 'FILE' }]) handler = DIDSearchHandlerImpl(MOCK_ACTIVE_INSTANCE, rucio) with pytest.raises(WildcardDisallowedException): handler.search_did('scope', 'name%', 'all', 100) rucio.search_did.assert_called_once_with('scope', 'name', 'all', 100)
def test_search_did__without_wildcard__wildcard_disabled__should_return_correct_response( mocker, rucio): rucio.instance_config['wildcard_enabled'] = False mocker.patch.object(rucio, 'search_did', return_value=[{ 'scope': 'scope', 'name': 'name1', 'bytes': None, 'did_type': 'CONTAINER' }, { 'scope': 'scope', 'name': 'name2', 'bytes': None, 'did_type': 'DATASET' }, { 'scope': 'scope', 'name': 'name3', 'bytes': 123, 'did_type': 'FILE' }]) handler = DIDSearchHandlerImpl(MOCK_ACTIVE_INSTANCE, rucio) result = handler.search_did('scope', 'name', 'all', 100) rucio.search_did.assert_called_once_with('scope', 'name', 'all', 100) expected = [{ 'did': 'scope:name1', 'size': None, 'type': 'container' }, { 'did': 'scope:name2', 'size': None, 'type': 'dataset' }, { 'did': 'scope:name3', 'size': 123, 'type': 'file' }] assert result == expected, "Invalid return value"