Пример #1
0
class TestDummy(object):
    def setup(self):
        self.test_dir = os.path.join(tc.CONF.path_to("source"), "dummy")
        self.dummy = Dummy(target=self.test_dir)

    def teardown(self):
        tc.delete_it(self.test_dir)

    def test__str__(self):
        assert str(self.dummy) == "DummyTask: No source code to fetch."

    def test__with__(self):
        with self.dummy:
            assert self.dummy.ready

    @mock.patch("pakit.shell.Dummy.clean")
    def test__with__fails(self, _):
        os.makedirs(self.dummy.target)
        with pytest.raises(PakitError):
            with self.dummy:
                pass

    def test_download(self):
        with pytest.raises(NotImplementedError):
            self.dummy.download()

    def test_ready(self):
        with self.dummy:
            assert self.dummy.ready
            with open(os.path.join(self.dummy.target, "file"), "w") as fout:
                fout.write("Hello world.")
            assert not self.dummy.ready

    def test_src_hash(self):
        assert self.dummy.src_hash == "dummy_hash"
Пример #2
0
 def setup(self):
     self.test_dir = os.path.join(tc.CONF.path_to("source"), "dummy")
     self.dummy = Dummy(target=self.test_dir)
Пример #3
0
 def setup(self):
     self.test_dir = os.path.join(tc.CONF.path_to('source'), 'dummy')
     self.dummy = Dummy(target=self.test_dir)