Esempio n. 1
0
 def test_relative_path_from(self):
     p1 = self.test_path / 'a' / 'b' / 'c' / 'd'
     p2 = self.test_path / 'e' / 'f' / 'g' / 'h'
     e1 = AugmentedPath('..', '..', '..', 'a', 'b', 'c', 'd')
     e2 = AugmentedPath('..', '..', '..', 'e', 'f', 'g', 'h')
     p1rfp2 = p1.relative_path_from(p2)
     p2rfp1 = p2.relative_path_from(p1)
     assert e1 == p1rfp2, p1rfp2
     assert e2 == p2rfp1, p2rfp1
Esempio n. 2
0
    def setUp(self):
        self.test_link = AugmentedPath(test_base, 'evil-symlink')  # FIXME random needed ...
        if self.test_link.is_symlink():
            self.test_link.unlink()

        self.test_link.symlink_to('hello/there')

        self.test_path = AugmentedPath(test_base, 'aug-testpath')  # FIXME random needed ...
        if self.test_path.exists():
            self.test_path.rmtree(onerror=onerror)
Esempio n. 3
0
    def test_context(self):
        start = AugmentedPath.cwd()
        target = AugmentedPath(temp_path).resolve()  # resolve needed for osx
        distractor = AugmentedPath('~/').expanduser()
        assert temp_path.is_dir()
        with target:
            target_cwd = AugmentedPath.cwd()
            distractor.chdir()
            distractor_cwd = AugmentedPath.cwd()

        end = AugmentedPath.cwd()
        assert target == target_cwd, 'with target: failed'
        assert distractor == distractor_cwd, 'distractor cwd failed'
        assert start == end, 'it would seem that the distractor got us'
        assert start != target != distractor
Esempio n. 4
0
class Helper:
    @classmethod
    def setUpClass(cls):
        if not test_base.exists():
            test_base.mkdir()

    @classmethod
    def tearDownClass(cls):
        if test_base.exists():
            test_base.rmtree(onerror=onerror)

    def setUp(self):
        self.test_link = AugmentedPath(test_base, 'evil-symlink')  # FIXME random needed ...
        if self.test_link.is_symlink():
            self.test_link.unlink()

        self.test_link.symlink_to('hello/there')

        self.test_path = AugmentedPath(test_base, 'aug-testpath')  # FIXME random needed ...
        if self.test_path.exists():
            self.test_path.rmtree(onerror=onerror)

    def tearDown(self):
        if self.test_link.is_symlink():
            self.test_link.unlink()

        if self.test_path.exists():
            self.test_path.rmtree(onerror=onerror)
Esempio n. 5
0
    def setUp(self):
        class BlackfynnCache(BFC):
            pass

        base = AugmentedPath(__file__).parent / 'test-operation'

        if base.exists():
            base.popd()  # in case we were inside it pop back out first
            base.rmtree()

        base.mkdir()
        base.pushd()

        self.BlackfynnRemote = BlackfynnRemote._new(LocalPath, BlackfynnCache)
        self.BlackfynnRemote.init(test_organization)
        self.anchor = self.BlackfynnRemote.dropAnchor(base)
        self.root = self.anchor.remote
        self.project_path = self.anchor.local
        list(self.root.children)  # populate datasets
        self.test_base = [p for p in self.project_path.children if p.cache.id == test_dataset][0]
        asdf = self.root / 'lol' / 'lol' / 'lol (1)'

        class Fun(os.PathLike):
            name = 'hohohohohoho'

            def __fspath__(self):
                return ''

            @property
            def size(self):
                return FileSize(len(b''.join(self.data)))

            @property
            def data(self):
                for i in range(100):
                    yield b'0' * 1000

        wat = asdf.bfobject.upload(Fun(), use_agent=False)