def test_uninstallTemplate_symlink(freshBackend, datadir): B, tmp_path = freshBackend t1 = Path(datadir['t1']) B.installTemplate('t1', t1, True) B.uninstallTemplate('t1') target_templates = tmp_path / 'templates/t1' assert not target_templates.exists()
def test_withopt(simpleBackend, tmp_path, datadir): B, _ = simpleBackend t = Path(datadir['t']) tt = Path(datadir['tt']) r = Path(datadir['r']) B.execTemplate(t, str(tmp_path), [42, 43]) B.execTemplate(tt, str(tmp_path), [42, 43]) assertDirsEqual(r, tmp_path)
def doTestProcessing2(simpleBackend, tmp_path, datadir): B, _ = simpleBackend t = Path(datadir['t']) tt = Path(datadir['tt']) r = Path(datadir['r']) B.execTemplate(t, str(tmp_path), [42, 43]) B.execTemplate(tt, str(tmp_path), [42, 43]) assertDirsEqual(r, tmp_path)
def test_installTemplate_over(freshBackend, datadir): B, tmp_path = freshBackend t1 = Path(datadir['t1']) t2 = Path(datadir['t2']) B.installTemplate('t1', t1) B.installTemplate('t1', t2) target_templates = tmp_path / 'templates/t1' assertDirsEqual(target_templates, t2)
def test_sections(simpleBackend, tmp_path, datadir, datadir_copy): B, _ = simpleBackend doTestProcessing(simpleBackend, tmp_path, datadir) t = Path(datadir['t']) r2_ = Path(datadir_copy['r2_']) r2 = Path(datadir['r2']) B.execTemplate(t, str(r2_), None) assertDirsEqual(r2, r2_)
def test_sft_sc_help_docstring(simpleBackend, datadir): B, _ = simpleBackend t = Path(datadir['t']) b, h = B.execTemplate(t, '@help', None) assert not b assert 'Dummy help' == h b, h = B.execTemplate(t, '_help', ['--help']) assert not b assert 'Dummy help' == h
def test_prefixes(simpleBackend, tmp_path, datadir, dir): B, _ = simpleBackend d = Path(datadir[dir]) t = d / 't' tt = d / 'tt' r = d / 'r' B.execTemplate(t, str(tmp_path), [42, 43]) B.execTemplate(tt, str(tmp_path), [42, 43]) assertDirsEqual(r, tmp_path)
def test_sft_sc_help_forced(simpleBackend, tmp_path, datadir): B, _ = simpleBackend t = Path(datadir['t']) b, h = B.execTemplate(t, str(tmp_path / '_'), None) assert not b assert 'Dummy help' == h assert not (tmp_path / '_').exists()
def test_empty_dirs(simpleBackend, tmp_path, datadir): B, _ = simpleBackend t = Path(datadir['t']) r = Path(tmp_path / 'r') dirs = [ 'to_keep2', 'to_keep2/to_keep2_to_keep', 'to_keep2/to_keep2_to_keep2', 'to_keep2/moved', 'to_keep', 'to_keep/to_keep_to_keep2', 'to_keep/to_keep_to_keep', 'to_keep/moved', 'moved', 'moved/to_move_to_keep', 'moved/to_move_to_keep2', 'moved/moved', ] for d in dirs: Dvar(r"""d, r/d""") (r / d).mkdir(parents=True, exist_ok=True) B.execTemplate(t, str(tmp_path / 'o'), [42, 43]) assertDirsEqual(r, tmp_path / 'o')
def test_placeholder(simpleBackend, tmp_path, datadir, datadir_copy): B, _ = simpleBackend doTestProcessing(simpleBackend, tmp_path, datadir) t = Path(datadir['t']) r1_ = Path(datadir_copy['r1_']) r1 = Path(datadir['r1']) B.execTemplate(t, str(r1_), None) assertDirsEqual(r1, r1_) r2_ = Path(datadir_copy['r2_']) r2 = Path(datadir['r2']) B.execTemplate(t, str(r2_), None) assertDirsEqual(r2, r2_) r3_ = Path(datadir_copy['r3_']) r3 = Path(datadir['r3']) B.execTemplate(t, str(r3_), None) assertDirsEqual(r3, r3_) r4_ = Path(datadir_copy['r4_']) r4 = Path(datadir['r4']) B.execTemplate(t, str(r4_), None) assertDirsEqual(r4, r4_)
def test_installTemplate_symlink(freshBackend, datadir): B, tmp_path = freshBackend t1 = Path(datadir['t1']) B.installTemplate('t1', t1, True) target_templates = tmp_path / 'templates/t1' assertDirsEqual(target_templates, t1)
def test_installDefaultTemplates_symlink(freshBackend, datadir): B, tmp_path = freshBackend B.installDefaultTemplates(True) src_templates = datadir['default/templates'] target_templates = tmp_path / 'default/templates' assertDirsEqual(target_templates, src_templates)
def test_createConfig(tmp_path, datadir): from skbs.backend import Backend as B conf = datadir['default/conf.py'] B.createConfig(tmp_path / 'conf.py') assertFilesEqual(conf, tmp_path / 'conf.py')
def test_help(simpleBackend, datadir): B, _ = simpleBackend t = Path(datadir['t']) b, h = B.execTemplate(t, '@help', None) assert not b assert 'Dummy help' == h
def freshBackend(tmp_path): from skbs.backend import Backend from skbs.pluginutils import Config as C config = C(verbose=False, template_dir=tmp_path) return Backend(config), tmp_path
def simpleBackend(tmpdir_factory): tmp_path = tmpdir_factory.mktemp('dir') from skbs.backend import Backend from skbs.pluginutils import Config as C config = C(verbose=False, template_dir=tmp_path) return Backend(config), tmp_path
def doTestProcessingSFT(simpleBackend, tmp_path, datadir): B, _ = simpleBackend t = Path(datadir['t']) r = Path(datadir['r']) B.execTemplate(t, str(tmp_path / 'res'), [42, 43]) assertFilesEqual(r, tmp_path / 'res')