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'])
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')
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)
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]'))
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)
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")
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")
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"))
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()
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"))
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
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"))
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']
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")
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
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")
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'])
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'])
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'])
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)
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)
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']
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'])