<s> """<STR_LIT>""" <EOL> __docformat__ = '<STR_LIT>' <EOL> from os . path import basename , exists , isdir , join as opj <EOL> from mock import patch <EOL> from nose . tools import assert_is_instance , assert_not_in <EOL> from six . moves . urllib . parse import urlparse <EOL> from ... api import search_collection , import_metadata , install_handle , create_collection , add_handle , describe <EOL> from ... utils import swallow_logs , getpwd , chpwd <EOL> from ... tests . utils import ok_ , eq_ , assert_cwd_unchanged , assert_raises , with_testrepos , with_tempfile , ok_startswith , assert_in , ok_clean_git <EOL> from ... cmdline . helpers import get_repo_instance , get_datalad_master <EOL> from ... support . handle import Handle <EOL> from ... support . collection import Collection <EOL> from ... support . metadatahandler import DLNS , PAV , DCTERMS , URIRef , RDF , FOAF , PROV , Literal , Graph <EOL> from ... support . handlerepo import HandleRepo <EOL> from ... consts import REPO_CONFIG_FILE , REPO_STD_META_FILE , HANDLE_META_DIR <EOL> @ assert_cwd_unchanged <EOL> @ with_testrepos ( '<STR_LIT>' , flavors = [ '<STR_LIT>' ] ) <EOL> @ with_tempfile <EOL> @ with_tempfile <EOL> @ with_tempfile ( mkdir = True ) <EOL> def test_search_collection ( hurl , hpath , cpath , lcpath ) : <EOL> class mocked_dirs : <EOL> user_data_dir = lcpath <EOL> with patch ( '<STR_LIT>' , mocked_dirs ) , swallow_logs ( ) as cml : <EOL> handle = install_handle ( hurl , hpath ) <EOL> collection = create_collection ( cpath ) <EOL> add_handle ( hpath , cpath ) <EOL> current_dir = getpwd ( ) <EOL> chpwd ( cpath ) <EOL> import_metadata ( format = "<STR_LIT>" , path = hpath , handle = handle . name ) <EOL> clist = search_collection ( "<STR_LIT>" ) <EOL> assert_is_instance ( clist , list ) <EOL> eq_ ( clist , [ ] ) <EOL> describe ( author = "<STR_LIT>" , <EOL> description = "<STR_LIT>" ) <EOL> chpwd ( current_dir ) <EOL> clist = search_collection ( "<STR_LIT>" ) <EOL> assert_is_instance ( clist , list ) <EOL> for item in clist : <EOL> assert_is_instance ( item , Collection ) <EOL> eq_ ( len ( clist ) , <NUM_LIT:1> ) <EOL> eq_ ( clist [ <NUM_LIT:0> ] . name , collection . name ) <EOL> eq_ ( urlparse ( clist [ <NUM_LIT:0> ] . url ) . path , cpath ) </s>
