Example #1
0
    def test_venv_local(self, config_deps: Mock, config: VenvConfig) -> None:
        config_read(config_deps,
                    {self.CWD_sv_cfg: "[pip.test]\nlocation = ~\n"})

        config.load()

        assert path.join('~', '.sv') in str(config.venvs['pip.test'])
Example #2
0
    def test_config_search_list(self, config_deps: Mock, config: VenvConfig):
        config.search_path(['Test', 'Path'])

        config.load()

        config_deps.exists.assert_any_call(Path('Test').absolute() / '.sv_cfg')
        config_deps.exists.assert_any_call(Path('Path').absolute() / '.sv_cfg')
Example #3
0
    def test_venv_config_venvs(self, config_deps: Mock,
                               config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[sample]\n[pip]\n"})

        config.load()

        assert {'sample', 'pip'} <= set(config.venvs)
Example #4
0
    def test_list_basic(self, config_deps: Mock, config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[test]\n"})

        config.load()
        config.list()

        config_deps.echo.assert_called_with(
            path.join('test (.sv', 'test) [.sv_cfg]'))
Example #5
0
    def test_venv_config_scripts(self, config_deps: Mock,
                                 config: VenvConfig) -> None:
        config_read(
            config_deps,
            {self.CWD_sv_cfg: "[SCRIPTS]\nsample.py=sample\npip=sample"})

        config.load()

        assert {'sample.py', 'pip'} <= set(config.scripts)
Example #6
0
    def test_create_missing(self, config_deps: Mock,
                            config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[test]"})
        config.load()

        config.create('other')

        config_deps.echo.assert_called_with(
            "Unable to find venv or script other")
Example #7
0
    def test_list_scripts(self, config_deps: Mock, config: VenvConfig) -> None:
        config_read(
            config_deps,
            {self.CWD_sv_cfg: "[SCRIPTS]\nsample = test\ntester = test"})
        config.load()

        config.list()

        config_deps.echo.assert_called_with("\tScripts: sample, tester")
Example #8
0
    def test_venv_config_ignored(self, config_deps: Mock,
                                 config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[Sample]\n[pip.Test]\n"})

        config.load()

        assert not config.venvs
        config_deps.echo.assert_called_with(
            StringContaining("Sample, pip.Test"))
Example #9
0
    def test_create_exists(self, venv_deps: Mock, config_deps: Mock,
                           config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[test]"})
        venv_exists(venv_deps, self.CWD_sv_test)
        config.load()

        config.create('test')

        venv_deps.echo.assert_not_called()
Example #10
0
    def test_create_update(self, venv_deps: Mock, config_deps: Mock,
                           config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[test]"})
        venv_exists(venv_deps, self.CWD_sv_test)
        config.load()

        config.create('test', update=True)

        venv_deps.echo.assert_called_with(
            StringContaining("Updating venv test"))
Example #11
0
    def test_venv_requirements(self, config_deps: Mock,
                               config: VenvConfig) -> None:
        config_read(
            config_deps,
            {self.CWD_sv_cfg: "[sample]\nrequirements = alpha\n\tbeta\n"})

        config.load()

        venv = config.venvs['sample']
        assert {'alpha', 'beta'} == venv.requirements
Example #12
0
    def test_create_script(self, venv_deps: Mock, config_deps: Mock,
                           config: VenvConfig) -> None:
        venv_exists(venv_deps)
        config_read(config_deps, {self.CWD_sv_cfg: "[SCRIPTS]\ntester = test"})
        config.load()

        config.create('tester')

        venv_deps.echo.assert_called_with(
            StringContaining("Creating venv test"))
Example #13
0
    def test_venv_config_load(self, config_deps: Mock,
                              config: VenvConfig) -> None:
        config_read(config_deps,
                    {self.CWD_sv_cfg: "[SCRIPTS]\nsample.py=sample"})

        config.load()

        assert 'sample.py' in config.scripts
        assert 'sample' in config.venvs
        assert 'sample' == config.scripts['sample.py']
Example #14
0
    def test_list_prerequisites(self, config_deps: Mock,
                                config: VenvConfig) -> None:
        config_read(
            config_deps,
            {self.CWD_sv_cfg: "[test]\nprerequisites = beta\n\talpha\n"})
        config.load()

        config.list()

        config_deps.echo.assert_called_with("\tPrerequisites: alpha\n\t\tbeta")
Example #15
0
    def test_venv_prerequisites(self, config_deps: Mock,
                                config: VenvConfig) -> None:
        config_read(
            config_deps,
            {self.CWD_sv_cfg: "[sample]\nprerequisites = first\n\tsecond\n"})

        config.load()

        venv = config.venvs['sample']
        assert {'first', 'second'} == venv.prerequisites
Example #16
0
    def test_list_requirements(self, config_deps: Mock,
                               config: VenvConfig) -> None:
        config_read(
            config_deps,
            {self.CWD_sv_cfg: "[test]\nrequirements = second\n\tfirst\n"})
        config.load()

        config.list()

        config_deps.echo.assert_called_with(
            "\tRequirements: first\n\t\tsecond")
Example #17
0
def test_venv_local(venv_config: VenvConfig) -> None:
    venv_config.load(True, in_file=StringIO("[pip.test]\nlocal"))

    assert '~' not in str(venv_config.venvs['pip.test'])
Example #18
0
def test_venv_global(venv_config: VenvConfig) -> None:
    venv_config.load(False, in_file=StringIO("[pip.test]\nglobal"))

    assert '~' in str(venv_config.venvs['pip.test'])
Example #19
0
def test_venv_current(venv_config: VenvConfig) -> None:
    venv_config.load(False, in_file=StringIO("[pip.test]\n"))

    assert '~' not in str(venv_config.venvs['pip.test'])
Example #20
0
def venv_config_venvs(venv_config: VenvConfig) -> None:
    venv_config.load(False, in_file=StringIO("[sample]\n[pip]"))

    assert {'sample', 'pip'} <= set(venv_config.venvs)
Example #21
0
def venv_config_scripts(venv_config: VenvConfig) -> None:
    venv_config.load(
        False, in_file=StringIO("[SCRIPTS]\nsample.py=sample\npip=sample"))

    assert {'pip', 'sample.py'} <= set(venv_config.scripts)
Example #22
0
def venv_config_load(venv_config: VenvConfig) -> None:
    venv_config.load(False, in_file=StringIO("[SCRIPTS]\nsample.py=sample"))

    assert 'sample.py' in venv_config.scripts
    assert 'sample' in venv_config.venvs
    assert 'sample' == venv_config.scripts['sample.py']
Example #23
0
    def test_venv_current(self, config_deps: Mock, config: VenvConfig) -> None:
        config_read(config_deps, {self.CWD_sv_cfg: "[pip.test]\n"})

        config.load()

        assert '~' not in str(config.venvs['pip.test'])