def test_register_global(self, config_deps: Mock, config: VenvConfig) -> None: config_read(config_deps, {}) config_write(config_deps) config_scripts(config_deps) config.register('test', ('package', ), config_path='~/.config') config_deps.echo.assert_called_with(StringContaining("Registering")) assert self.USER_sv_cfg in config_deps.out_str out_str = config_deps.out_str[self.USER_sv_cfg] assert "requirements = package" in out_str
def test_register_scripts(self, config_deps: Mock, config: VenvConfig) -> None: config_read(config_deps, {}) config_write(config_deps) config_scripts(config_deps) config.register('test', ('package1', 'package2'), config_path='Test') config_deps.echo.assert_called_with(StringContaining("Registering")) test_sv_cfg = path.expandvars(path.join('$CWD', 'Test', '.sv_cfg')) assert test_sv_cfg in config_deps.out_str out_str = config_deps.out_str[test_sv_cfg] assert "package1.script = test" in out_str assert "package2.script = test" in out_str assert "requirements = package1\n\tpackage2" in out_str
def test_register(self, config_deps: Mock, config: VenvConfig) -> None: config_read(config_deps, {}) config_write(config_deps) config_scripts(config_deps) config.register('test', ('package', )) config_deps.echo.assert_called_with(StringContaining("Registering")) sv_cfg = path.abspath('.sv_cfg') assert sv_cfg in config_deps.out_str out_str = config_deps.out_str[sv_cfg] assert "[test]" in out_str assert "requirements = package" in out_str assert "global" not in out_str assert "local" not in out_str
def test_register_scripts(venv_config: VenvConfig) -> None: out_file = StringIO() def test_scripts(package: str) -> Iterable[str]: return [package + '.script'] venv_config.register('test', ('package1', 'package2'), False, False, out_file=out_file, package_scripts=test_scripts) out_str = out_file.getvalue() assert "package1.script = test" in out_str assert "package2.script = test" in out_str assert "requirements = package1\n\tpackage2" in out_str
def test_register_global(venv_config: VenvConfig) -> None: out_file = StringIO() def test_scripts(_package: str) -> Iterable[str]: return [] venv_config.register('test', ('package', ), False, False, out_file=out_file, package_scripts=test_scripts) out_str = out_file.getvalue() assert "global\n" in out_str assert "requirements = package" in out_str assert "local" not in out_str
def test_register_existing(self, config_deps: Mock, config: VenvConfig) -> None: config_read( config_deps, { self.CWD_sv_cfg: """[SCRIPTS]\nsample = test\n\n[test]\nprerequisites = early\nrequirements = old\n""" }) config_write(config_deps) config_scripts(config_deps) config.register('test', ('new', ), config_path='.') config_deps.echo.assert_called_with(StringContaining("Registering")) assert self.CWD_sv_cfg in config_deps.out_str out_str = config_deps.out_str[self.CWD_sv_cfg] assert "[test]" in out_str assert "[SCRIPTS]" in out_str assert "prerequisites = early" in out_str assert "requirements = new\n\told" in out_str assert "global" not in out_str assert "local" not in out_str