Пример #1
0
 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
Пример #2
0
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)
Пример #3
0
 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)
Пример #4
0
 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'))
Пример #5
0
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')
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
    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
Пример #9
0
    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")
Пример #10
0
    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')
Пример #11
0
 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
Пример #12
0
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)
Пример #13
0
 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)
Пример #14
0
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)
Пример #15
0
 def test_search_config_one_up(self):
     tc.delete_it(self.third_conf)
     assert search_for_config() == self.second_conf
Пример #16
0
 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)
Пример #17
0
 def teardown(self):
     tc.delete_it(self.test_module)
Пример #18
0
 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'))
Пример #19
0
 def teardown(self):
     tc.delete_it(self.conf_file)
     pakit.conf.CONFIG = self.old_conf
     pakit.recipe.RDB = self.old_rdb
Пример #20
0
 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
Пример #21
0
 def teardown(self):
     tc.delete_it(self.idb_file)
Пример #22
0
 def teardown(self):
     tc.delete_it(self.fname)
Пример #23
0
 def teardown(self):
     tc.delete_it(self.config_file)
Пример #24
0
 def teardown(self):
     tc.delete_it(self.src)
     tc.delete_it(self.dst)
Пример #25
0
 def teardown(self):
     tc.delete_it(self.test_dir)
Пример #26
0
 def teardown(self):
     tc.delete_it(self.target)
Пример #27
0
 def teardown(self):
     tc.delete_it(self.archive.arc_file)
     tc.delete_it(self.test_dir)