Пример #1
0
    def setUp(self):
        # this by itself will cause an error due to lack of __init__ in /tmp/
        # even without running even_when_transient
        #madpath = Path('/tmp/test_madness.py')

        self.madpath = aug.AugmentedPath(__file__).parent / 'madness/test_madness.py'
        if not self.madpath.parent.exists():
            self.madpath.parent.mkdir()
            (self.madpath.parent / '__init__.py').touch()

        with open(self.madpath, 'wt') as f:
            f.write(test_madness_py)
Пример #2
0
    def test_stale_repo_cache(self):
        rp = self.test_init()
        rp.repo
        aug.AugmentedPath(
            rp).rmtree()  # have to call rmtree that won't invoke repo.close()
        try:
            rp.repo
            assert False, 'should have failed'
        except exc.NotInRepoError:
            pass

        rp2 = RepoPath(rp)
        try:
            rp2.repo
            assert False, 'should have failed'
        except exc.NotInRepoError:
            pass
Пример #3
0
    def setUp(self):
        class Cache(self._cache_class):
            pass

        Cache._bind_flavours()

        base = aug.AugmentedPath(__file__).parent / f'test-operation-{_pid}'

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

        base.mkdir()
        base.pushd()

        self.Remote = self._remote_class._new(LocalPath, Cache)
        self.Remote.init(test_organization)
        self.anchor = self.Remote.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]
        list(self.test_base.rchildren)  # populate test dataset

        asdf = self.root / 'lol' / 'lol' / 'lol (1)'

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

            def __fspath__(self):
                return ''

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

            @property
            def data(self):
                for i in range(100):
                    yield b'0' * 1000
Пример #4
0
        post_load = lambda: (
            this_repo.remove_diff_untracked(),
            this_repo.checkout_diff_tracked(),
        )
        post_main = lambda: (
            this_repo.remove_diff_untracked(),
            this_repo.checkout_diff_tracked(),
        )

    else:
        post_load = lambda: None
        post_main = lambda: None

do_mains = True

default_dir = aug.AugmentedPath(__file__).parent

_test_ttl = (default_dir / 'graphload-test.ttl')
test_ttl = _test_ttl.as_posix()
_test_owl = (default_dir / 'owl-test.ttl')
test_owl = _test_owl.as_posix()
_temp_git = aug.RepoPath(temp_path) / 'git-test'
temp_git = _temp_git.as_posix()

nsmethodsobo = (glb /
                'methodsOntology/source-material/ns_methods.obo').as_posix()

### build mains

mains = {
    'scigraph':
Пример #5
0
 def tearDownClass(cls):
     base = aug.AugmentedPath(__file__).parent / f'test-operation-{_pid}'
     if base.exists():
         base.popd()  # in case we were inside it pop back out first
         base.rmtree()
Пример #6
0
import unittest
import pathlib as pl
import pytest
import ontquery as oq
import augpathlib as aug
from pyontutils import sneechenator as snch
from pyontutils.core import OntGraph
from pyontutils.config import auth
from pyontutils.namespaces import rdf
from pyontutils.integration_test_helper import Repo
from .common import temp_path

skipif_no_ont = pytest.mark.skipif(
    auth.get_path('ontology-local-repo') is not None,
    reason='Skipping due to missing ontology repo')
temp_path_aug = aug.AugmentedPath(temp_path)
sfy = pl.Path(__file__).parent / 'sneech-file.yaml'
sft = pl.Path(__file__).parent / 'sneech-file.ttl'


def fix_file(path):
    with open(path, 'rt') as f:
        sin = f.read()

    sout = sin.replace(
        '~/git/NIF-Ontology',
        auth.get_path('ontology-local-repo').resolve().as_posix())
    with open(path, 'wt') as f:
        f.write(sout)

    return sin
Пример #7
0
import augpathlib as aug
from augpathlib import exceptions as exc
from augpathlib import LocalPath
from augpathlib import PrimaryCache, RemotePath
from augpathlib import EatCache, SymlinkCache
from augpathlib import PathMeta
from augpathlib.utils import onerror_windows_readwrite_remove

aug.utils.log.setLevel('DEBUG')
log = aug.utils.log.getChild('test')

onerror = onerror_windows_readwrite_remove if os.name == 'nt' else None

_pid = os.getpid()
this_file = LocalPath(__file__)
temp_path = aug.AugmentedPath(gettempdir(), f'.augpathlib-testing-base-{_pid}')
project_path = this_file.parent / 'test_local/test_project'

SKIP_NETWORK = ('SKIP_NETWORK' in os.environ or
                'FEATURES' in os.environ and 'network-sandbox' in os.environ['FEATURES'])
skipif_no_net = pytest.mark.skipif(SKIP_NETWORK, reason='Skipping due to network requirement')


class LocalPathTest(LocalPath):
    def metaAtTime(self, time):
        # we are cheating in order to do this
        return PathMeta(id=self._cache_class._remote_class.invAtTime(self, time))


LocalPathTest._bind_flavours()