Beispiel #1
0
 def newfunc(*args, **kwargs):
     from datalad.ui import ui
     old_backend = ui.backend
     try:
         ui.set_backend('tests' if interactive else 'tests-noninteractive')
         if responses:
             ui.add_responses(responses)
         ret = t(*args, **kwargs)
         if responses:
             responses_left = ui.get_responses()
             assert not len(responses_left), "Some responses were left not used: %s" % str(responses_left)
         return ret
     finally:
         ui.set_backend(old_backend)
Beispiel #2
0
 def newfunc(*args, **kwargs):
     from datalad.ui import ui
     old_backend = ui.backend
     try:
         ui.set_backend('tests' if interactive else 'tests-noninteractive')
         if responses:
             ui.add_responses(responses)
         ret = t(*args, **kwargs)
         if responses:
             responses_left = ui.get_responses()
             assert not len(responses_left), "Some responses were left not used: %s" % str(responses_left)
         return ret
     finally:
         ui.set_backend(old_backend)
Beispiel #3
0
def test_search_outside1_install_default_ds(tdir, default_dspath):
    with chpwd(tdir):
        # let's mock out even actual install/search calls
        with \
            patch_config({'datalad.locations.default-dataset': default_dspath}), \
            patch('datalad.api.install',
                  return_value=Dataset(default_dspath)) as mock_install, \
            patch('datalad.distribution.dataset.Dataset.search',
                  new_callable=_mock_search):
            _check_mocked_install(default_dspath, mock_install)

            # now on subsequent run, we want to mock as if dataset already exists
            # at central location and then do search again
            from datalad.ui import ui
            ui.add_responses('yes')
            mock_install.reset_mock()
            with patch('datalad.distribution.dataset.Dataset.is_installed',
                       True):
                _check_mocked_install(default_dspath, mock_install)

            # and what if we say "no" to install?
            ui.add_responses('no')
            mock_install.reset_mock()
            with assert_raises(NoDatasetArgumentFound):
                list(search("."))

            # and if path exists and is a valid dataset and we say "no"
            Dataset(default_dspath).create()
            ui.add_responses('no')
            mock_install.reset_mock()
            with assert_raises(NoDatasetArgumentFound):
                list(search("."))
Beispiel #4
0
def test_search_outside1_install_default_ds(tdir, default_dspath):
    with chpwd(tdir):
        # let's mock out even actual install/search calls
        with \
            patch_config({'datalad.locations.default-dataset': default_dspath}), \
            patch('datalad.api.install',
                  return_value=Dataset(default_dspath)) as mock_install, \
            patch('datalad.distribution.dataset.Dataset.search',
                  new_callable=_mock_search):
            _check_mocked_install(default_dspath, mock_install)

            # now on subsequent run, we want to mock as if dataset already exists
            # at central location and then do search again
            from datalad.ui import ui
            ui.add_responses('yes')
            mock_install.reset_mock()
            with patch(
                    'datalad.distribution.dataset.Dataset.is_installed',
                    True):
                _check_mocked_install(default_dspath, mock_install)

            # and what if we say "no" to install?
            ui.add_responses('no')
            mock_install.reset_mock()
            with assert_raises(NoDatasetArgumentFound):
                list(search("."))

            # and if path exists and is a valid dataset and we say "no"
            Dataset(default_dspath).create()
            ui.add_responses('no')
            mock_install.reset_mock()
            with assert_raises(NoDatasetArgumentFound):
                list(search("."))