def test_builder_channels(self, mock_ospe, mock_base_local, mock_local, mock_repo_dir, mock_load_conf): mock_repo_dir.return_value = "REPO" mock_ospe.return_value = True mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock(return_value={ 'build': {'builder': 'conf'}, "conda_channels": ['conda-forge', 'ioam'], 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_load_conf.return_value = mock_conf plugin = FACTORY('Conda') plugin.create(clean=True, python='3.5') plugin.activate() mock_base_local.assert_has_calls([ mock.call('source REPO/venv/bin/activate REPO/venv && python setup.py develop') ]) mock_local.assert_has_calls([ mock.call('conda remove --all -y -p REPO/venv'), mock.call('conda install --no-update-dependencies -c conda-forge -c ioam --yes --file requirements.txt'), mock.call('conda install -c conda-forge -c ioam --yes --file test-requirements.txt'), mock.call('conda install -c conda-forge -c ioam --yes --file more-reqs.txt') ]) mock_base_local.reset_mock() plugin.create(clean=True, nosetupdevelop=True) self.failUnless(not mock_base_local.called)
def test_builder(self, mock_pip, mock_base_local, mock_local, mock_venv_cls, mock_repo_dir, mock_load_conf): mock_pip.return_value = "PIP_COMMAND" mock_repo_dir.return_value = "REPO" mock_venv = mock.Mock() mock_venv.open_or_create = mock.Mock() mock_venv_cls.return_value = mock_venv mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock(return_value={ 'build': {'builder': 'conf'}, 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_load_conf.return_value = mock_conf plugin = FACTORY('VirtualenvPip') plugin.create(clean=True) plugin.activate() mock_base_local.assert_has_calls([ mock.call('. REPO/venv/bin/activate && python setup.py develop') ]) mock_local.assert_has_calls([ mock.call('PIP_COMMAND'), mock.call('PIP_COMMAND'), mock.call('PIP_COMMAND') ]) mock_base_local.reset_mock() plugin.create(clean=True, nosetupdevelop=True) self.failUnless(not mock_base_local.called)
def test_builder_new_conda(self, mock_ospe, mock_base_local, mock_local, mock_repo_dir, mock_load_conf): mock_repo_dir.return_value = "REPO" pe_results = [True for x in range(17)] pe_results.extend([False, False]) mock_ospe.side_effect = pe_results mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock(return_value={ 'build': {'builder': 'conf'}, 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_load_conf.return_value = mock_conf plugin = FACTORY('CondaEnv') plugin.create(clean=True, upgrade=True, python='3.5', environment='env.yaml') plugin.activate() mock_base_local.assert_has_calls([ mock.call('source REPO/venv/bin/activate REPO/venv && python setup.py develop') ]) mock_local.assert_has_calls([ mock.call('conda remove --all -y -p REPO/venv'), mock.call('source REPO/venv/bin/activate REPO/venv && conda env update REPO/venv -f env.yaml') ]) mock_base_local.reset_mock() plugin.create(clean=True, nosetupdevelop=True, environment='env.yaml') self.failUnless(not mock_base_local.called)
def test_builder(self, mock_ospe, mock_pip, mock_base_local, mock_local, mock_repo_dir, mock_load_conf): mock_pip.return_value = "PIP_COMMAND" mock_repo_dir.return_value = "REPO" mock_ospe.return_value = True mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock(return_value={ 'build': {'builder': 'conf'}, 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_load_conf.return_value = mock_conf plugin = FACTORY('CondaPip') plugin.create(clean=True, python='3.5') plugin.activate() mock_base_local.assert_has_calls([ mock.call('source REPO/venv/bin/activate REPO/venv && python setup.py develop') ]) mock_local.assert_has_calls([ mock.call('conda remove --all -y -p REPO/venv'), mock.call('PIP_COMMAND'), mock.call('PIP_COMMAND'), mock.call('PIP_COMMAND') ]) mock_base_local.reset_mock() plugin.create(clean=True, nosetupdevelop=True) self.failUnless(not mock_base_local.called)
def test_builder_extra_conda(self, mock_ospe, mock_base_local, mock_local, mock_repo_dir, mock_load_conf): mock_repo_dir.return_value = "REPO" mock_ospe.return_value = True mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock(return_value={ 'build': {'builder': 'conf'}, 'extra_conda_requirements': 'extra-conda-requirements.txt', 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_conf.pip_options = mock.Mock(return_value="PIP_OPTIONS") mock_load_conf.return_value = mock_conf plugin = FACTORY('CondaEnv') plugin.create(clean=True, upgrade=True, python='3.5', environment='env.yaml') plugin.activate() mock_base_local.assert_has_calls([ mock.call('source REPO/venv/bin/activate REPO/venv && python setup.py develop') ]) mock_local.assert_has_calls([ mock.call('conda remove --all -y -p REPO/venv'), mock.call('source REPO/venv/bin/activate REPO/venv && conda env update REPO/venv -f env.yaml'), mock.call('source REPO/venv/bin/activate REPO/venv && conda install REPO/venv -f extra-conda-requirements.txt') ]) mock_base_local.reset_mock() plugin.create(clean=True, nosetupdevelop=True, environment='env.yaml') self.failUnless(not mock_base_local.called)
def test_builder(self, mock_pip, mock_base_local, mock_local, mock_venv_cls, mock_repo_dir, mock_load_conf): mock_pip.return_value = "PIP_COMMAND" mock_repo_dir.return_value = "REPO" mock_venv = mock.Mock() mock_venv.open_or_create = mock.Mock() mock_venv_cls.return_value = mock_venv mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock( return_value={ 'build': { 'builder': 'conf' }, 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_load_conf.return_value = mock_conf plugin = FACTORY('VirtualenvPip') plugin.create(clean=True) plugin.activate() mock_base_local.assert_has_calls( [mock.call('. REPO/venv/bin/activate && python setup.py develop')]) mock_local.assert_has_calls([ mock.call('PIP_COMMAND'), mock.call('PIP_COMMAND'), mock.call('PIP_COMMAND') ]) mock_base_local.reset_mock() plugin.create(clean=True, nosetupdevelop=True) self.failUnless(not mock_base_local.called)
def tox_run(config, opts): """ tox test activate venv and run tox test suite """ suite_conf = config.test_suite(opts.suite) tox_ini = suite_conf.get('tox_ini') test_opts = suite_conf.get('test_options') if opts.options: # command line overrides test_opts = opts.options tox_command = "tox" if tox_ini: tox_command += " -c {}".format(tox_ini) if test_opts: tox_command += " {}".format(test_opts) if opts.builder is None: opts.builder = get_builder_plugin() builder = FACTORY(opts.builder) activate = builder.activate() local( '{0} && {1}'.format( activate, tox_command ) )
def nose_run(config, opts): """ _nose_test_ Locally activate vitrualenv and run tests via nose """ where = config.test_where(opts.suite) suite_conf = config.test_suite(opts.suite) test_opts = suite_conf.get('test_options') if opts.options: # command line overrides test_opts = opts.options if opts.builder is None: opts.builder = get_builder_plugin() builder = FACTORY(opts.builder) activate = builder.activate() local( '{0} && nosetests -w {1} {2}'.format( activate, where, test_opts if test_opts else "" ) )
def pytest_run(config, opts): """ activate venv and run pytest """ suite_conf = config.test_suite(opts.suite) test_opts = suite_conf.get('test_options') where = suite_conf.get('where', 'tests/unit') if opts.options: # command line overrides test_opts = opts.options command = "pytest {}".format(where) if test_opts: command += " {}".format(test_opts) if opts.builder is None: opts.builder = get_builder_plugin() builder = FACTORY(opts.builder) activate = builder.activate() local( '{0} && {1}'.format( activate, command ) )
def test_activate(self, mock_ospe, mock_pip, mock_base_local, mock_local, mock_repo_dir, mock_load_conf): mock_pip.return_value = "PIP_COMMAND" mock_repo_dir.return_value = "REPO" mock_ospe.return_value = True mock_conf = mock.Mock(name="load_configuration") mock_conf.get = mock.Mock(return_value={ 'build': {'builder': 'conf'}, 'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'] }) mock_load_conf.return_value = mock_conf plugin = FACTORY('Conda') self.assertEqual( plugin.activate(), "source REPO/venv/bin/activate REPO/venv" ) mock_ospe.return_value = False self.assertEqual(plugin.activate(), "source activate REPO/venv")