def test_starter_copy(params, tmpdir): tmpdir = str(tmpdir) params.TEMPLATES = ['custom'] params.TARGET = tmpdir starter = Starter(params, TESTDIR) assert starter.parser.default['_TRGDIR'] == tmpdir templates = starter.prepare_templates() assert [t.name for t in templates] == ['include', 'john', 'custom'] starter.copy() assert op.isfile(op.join(tmpdir, 'root_file')) assert op.isfile(op.join(tmpdir, 'dir', 'file')) t = op.join(tmpdir, 'dir', 'template') with open(t) as f: body = f.read() assert tmpdir in body assert 'customvalue' in body assert 'boss = %s' % starter.parser.default['_USER'] in body f = op.join(tmpdir, 'test_customvalue.ls') with open(f) as f: assert f
def test_starter_copy(self): target_dir = mkdtemp() self.params.TEMPLATES = ['custom'] self.params.TARGET = target_dir starter = Starter(self.params, TESTDIR) self.assertEqual(starter.parser.default['deploy_dir'], target_dir) templates = starter.prepare_templates() self.assertTrue(templates) starter.copy() self.assertTrue(op.isfile(op.join(target_dir, 'root_file'))) self.assertTrue(op.isfile(op.join(target_dir, 'dir', 'file'))) t = op.join(target_dir, 'dir', 'template') with open(t) as f: body = f.read() self.assertTrue(target_dir in body) self.assertTrue('customvalue' in body) self.assertTrue('boss = {0}'.format( starter.parser.default['USER']) in body) f = op.join(target_dir, 'test_customvalue.ls') with open(f) as f: self.assertTrue(f)
def test_template_not_found(self): self.params.TEMPLATES = ['custom2'] starter = Starter(self.params, TESTDIR) try: starter.copy() except ValueError as e: self.assertTrue(e) except: raise
def test_builtin_templates(params, tmpdir): tmpdir = str(tmpdir) params.TEMPLATES = ['py-package'] params.TARGET = tmpdir starter = Starter(params) starter.parser.default['AUTHOR_NAME'] = 'John Conor' starter.copy() assert starter.parser.default['AUTHOR_NAME'] == 'John Conor' with open(op.join(tmpdir, 'LICENSE')) as f: body = f.read() assert ("Copyright (c) {0}, {1}".format( starter.parser.default['_DATETIME'][:4], starter.parser.default['AUTHOR_NAME']) in body)
def test_builtin_templates(self): target_dir = mkdtemp() self.params.TEMPLATES = ['python-module'] self.params.TARGET = target_dir starter = Starter(self.params) self.params.TARGET = mkdtemp() starter.parser.default['AUTHOR_NAME'] = 'John Conor' starter.copy() self.assertEqual(starter.parser.default['AUTHOR_NAME'], 'John Conor') with open(op.join(target_dir, 'LICENSE')) as f: body = f.read() self.assertTrue( "Copyright (c) {0} by {1}".format(starter.parser.default[ 'datetime'][:4], starter.parser.default['AUTHOR_NAME']) in body)
def test_list_templates(params): starter = Starter(params) assert 'py-package' in [t.name for t in starter.iterate_templates()] starter = Starter(params, TESTDIR) assert 'custom' in [t.name for t in starter.iterate_templates()]
def test_template_not_found(params): params.TEMPLATES = ['custom2'] starter = Starter(params, TESTDIR) with pytest.raises(ValueError): starter.copy()
def test_list_templates(self): starter = Starter(self.params) self.assertTrue('python-module' in starter.list_templates()) starter = Starter(self.params, TESTDIR) self.assertTrue('custom' in starter.list_templates())