def test_search_config_default(self): tc.delete_it(self.third_conf) tc.delete_it(self.second_conf) tc.delete_it(self.first_conf) tc.delete_it(self.home_conf) tc.delete_it(self.home_pakit_conf) assert search_for_config(1) == 1
def test_unlink_man_pages(): try: link_dir = os.path.join(tc.STAGING, 'links') src = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'pakit', 'extra') fake_man = os.path.join(src, 'test_man.1') try: os.makedirs(os.path.dirname(fake_man)) except OSError: pass with open(fake_man, 'w') as fout: fout.write('hello') link_man_pages(link_dir) unlink_man_pages(link_dir) expected_man = os.path.join(link_dir, 'share', 'man', 'man1', os.path.basename(fake_man)) assert not os.path.exists(expected_man) assert not os.path.exists(os.path.dirname(expected_man)) assert os.path.isdir(link_dir) finally: tc.delete_it(fake_man) tc.delete_it(link_dir)
def test_change_dir_attribute(self): try: DummyRecipe.verify = DecChangeDir(attr='idir')(DummyRecipe.verify) dummy = DummyRecipe() dummy.idir = tempfile.mkdtemp() dummy.verify(dummy.idir) finally: tc.delete_it(dummy.idir)
def test_relink(self): recipe = self.recipe InstallTask(recipe).run() tc.delete_it(recipe.link_dir) assert not os.path.exists(recipe.link_dir) RelinkRecipes().run() assert sorted(os.listdir(recipe.link_dir)) == ['bin', 'share'] assert os.path.islink(os.path.join(recipe.link_dir, 'bin', 'ag'))
def test_delete_it_dir(): os.makedirs('tdir') afile = os.path.join('tdir', 'dummy') for i in range(0, 5): with open(afile + str(i), 'wb') as fout: fout.write('A simple line.'.encode()) tc.delete_it('tdir') assert not os.path.exists('tdir')
def test_decorator_combined(self): try: tmp_dir = tempfile.mkdtemp() DummyRecipe.verify = DecChangeDir('/tmp')(DummyRecipe.verify) DummyRecipe.verify = DecChangeDir(tmp_dir)(DummyRecipe.verify) dummy = DummyRecipe() dummy.verify(tmp_dir) finally: tc.delete_it(tmp_dir)
def test_write(self, mock_print): try: conf_file = os.path.join(tc.STAGING, 'dummy.yml') CreateConfig(conf_file).run() assert os.path.exists(conf_file) expect = 'Wrote default config to' mock_print.assert_any_call(expect, conf_file) finally: tc.delete_it(conf_file)
def test_check_for_deletions(self): self.manager = RecipeManager(self.config) self.manager.init_new_uris() path = os.path.join(self.config.path_to("recipes"), self.manager.uri_db[self.git_uri]["path"]) tc.delete_it(path) assert not os.path.exists(path) assert self.git_uri in self.manager.uri_db self.manager.check_for_deletions() assert self.git_uri not in self.manager.uri_db
def test_command_dir(self): try: os.makedirs("dummy") with open("dummy/hello", "wb") as fout: fout.write("this is a sample line".encode()) cmd = Command("ls", os.path.abspath("./dummy")) cmd.wait() assert cmd.rcode == 0 assert cmd.output() == ["hello"] finally: tc.delete_it("dummy")
def test_command_dir(self): try: os.makedirs('dummy') with open('dummy/hello', 'wb') as fout: fout.write('this is a sample line'.encode()) cmd = Command('ls', os.path.abspath('./dummy')) cmd.wait() assert cmd.rcode == 0 assert cmd.output() == ['hello'] finally: tc.delete_it('dummy')
def test_cmd_dir_arg(self): try: test_dir = os.path.join('/tmp', 'pakit_folder') try: os.makedirs(test_dir) except OSError: pass cmd = self.recipe.cmd('pwd', cmd_dir=test_dir) assert cmd.output() == [test_dir] finally: try: tc.delete_it(test_dir) except OSError: pass
def test_link_man_pages(): try: link_dir = os.path.join(tc.STAGING, "links") src = os.path.join(os.path.dirname(os.path.dirname(__file__)), "pakit", "extra") fake_man = os.path.join(src, "test_man.1") try: os.makedirs(os.path.dirname(fake_man)) except OSError: pass with open(fake_man, "w") as fout: fout.write("hello") link_man_pages(link_dir) assert os.path.islink(os.path.join(link_dir, "share", "man", "man1", os.path.basename(fake_man))) finally: tc.delete_it(fake_man) tc.delete_it(link_dir)
def teardown(self): tc.delete_it(self.recipe.install_dir) tc.delete_it(self.recipe.link_dir) tc.delete_it(self.recipe.source_dir) try: self.recipe.repo.clean() except PakitCmdError: pass os.makedirs(self.recipe.link_dir)
def test_delete_it_file(): afile = 'dummy' with open(afile, 'wb') as fout: fout.write('A simple line.'.encode()) tc.delete_it(afile) assert not os.path.exists(afile)
def test_search_config_one_up(self): tc.delete_it(self.third_conf) assert search_for_config() == self.second_conf
def teardown(self): os.chdir(self.orig_dir) tc.delete_it(self.test_dir) tc.delete_it(self.home_conf) tc.delete_it(self.home_pakit_conf)
def teardown(self): tc.delete_it(self.test_module)
def teardown(self): if self.manager: tc.delete_it(self.manager.uri_db.filename) tc.delete_it(self.config.path_to('recipes')) os.makedirs(self.config.path_to('recipes'))
def teardown(self): tc.delete_it(self.conf_file) pakit.conf.CONFIG = self.old_conf pakit.recipe.RDB = self.old_rdb
def test_search_config_home(self): tc.delete_it(self.third_conf) tc.delete_it(self.second_conf) tc.delete_it(self.first_conf) assert search_for_config() == self.home_conf
def teardown(self): tc.delete_it(self.idb_file)
def teardown(self): tc.delete_it(self.fname)
def teardown(self): tc.delete_it(self.config_file)
def teardown(self): tc.delete_it(self.src) tc.delete_it(self.dst)
def teardown(self): tc.delete_it(self.test_dir)
def teardown(self): tc.delete_it(self.target)
def teardown(self): tc.delete_it(self.archive.arc_file) tc.delete_it(self.test_dir)