示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    def test_builder_python_bin(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 = False
        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'],
            'python': '6.7'
        })
        mock_load_conf.return_value = mock_conf
        plugin = FACTORY('CondaPip')
        self.assertEqual(plugin.python_bin, '6.7')
        self.assertEqual(plugin.python_bin_for_conda, '6.7')
        plugin.create()
        mock_local.assert_has_calls([
            mock.call('conda create -y -m -p REPO/venv pip virtualenv python=6.7')
        ])

        # verify that pythonX.Y format also works
        mock_local.reset_mock()
        mock_conf.get = mock.Mock(return_value={
            'build': {'builder': 'conf'},
            'extra_requirements': ['test-requirements.txt', 'more-reqs.txt'],
            'python': 'python6.7'
        })
        mock_load_conf.return_value = mock_conf
        plugin2 = FACTORY('CondaPip')
        self.assertEqual(plugin2.python_bin, 'python6.7')
        self.assertEqual(plugin2.python_bin_for_conda, '6.7')
        plugin2.create()
        mock_local.assert_has_calls([
            mock.call('conda create -y -m -p REPO/venv pip virtualenv python=6.7')
        ])
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    def test_builder_python_bin(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'],
                'python': 'python6.7'
            })
        mock_load_conf.return_value = mock_conf
        plugin = FACTORY('VirtualenvPip')
        plugin.create(clean=True)

        mock_venv_cls.assert_has_calls([
            mock.call('REPO/venv',
                      python='python6.7',
                      system_site_packages=False)
        ])

        # verify conda style python version works too
        mock_venv_cls.reset_mock()
        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'],
                'python': '6.7'
            })
        mock_load_conf.return_value = mock_conf
        plugin2 = FACTORY('VirtualenvPip')
        plugin2.create(clean=True)

        mock_venv_cls.assert_has_calls([
            mock.call('REPO/venv',
                      python='python6.7',
                      system_site_packages=False)
        ])
示例#9
0
    def test_builder_python_bin(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'],
            'python': 'python6.7'
        })
        mock_load_conf.return_value = mock_conf
        plugin = FACTORY('VirtualenvPip')
        plugin.create(clean=True)

        mock_venv_cls.assert_has_calls([
            mock.call('REPO/venv', python='python6.7', system_site_packages=False)
        ])

        # verify conda style python version works too
        mock_venv_cls.reset_mock()
        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'],
            'python': '6.7'
        })
        mock_load_conf.return_value = mock_conf
        plugin2 = FACTORY('VirtualenvPip')
        plugin2.create(clean=True)

        mock_venv_cls.assert_has_calls([
            mock.call('REPO/venv', python='python6.7', system_site_packages=False)
        ])