def testCachedValidation(self): try: import dogpile.cache except: pass else: r = pathmap.get_test_repos() p = Phylesystem(r) nexson, sha = p.return_study('xy_10') r = p.add_validation_annotation(nexson, sha) cache_hits = p._cache_hits r1 = p.add_validation_annotation(nexson, sha) self.assertEqual(1 + cache_hits, p._cache_hits) self.assertEqual(r, r1) import sys; from peyotl import write_as_json; write_as_json(nexson, sys.stdout)
def testCachedValidation(self): try: # noinspection PyPackageRequirements import dogpile.cache except: pass else: r = pathmap.get_test_repos() p = Phylesystem(r) nexson, sha = p.return_study('xy_10') r = p.add_validation_annotation(nexson, sha) cache_hits = p._cache_hits r1 = p.add_validation_annotation(nexson, sha) self.assertEqual(1 + cache_hits, p._cache_hits) self.assertEqual(r, r1) write_as_json(nexson, sys.stdout)
def testCachedValidation(self): try: import dogpile.cache except: pass else: r = pathmap.get_test_repos() p = Phylesystem(r) nexson, sha = p.return_study('xy_10') r = p.add_validation_annotation(nexson, sha) cache_hits = p._cache_hits r1 = p.add_validation_annotation(nexson, sha) self.assertEqual(1 + cache_hits, p._cache_hits) self.assertEqual(r, r1) import sys from peyotl import write_as_json write_as_json(nexson, sys.stdout)
#! /usr/bin/env python import unittest from peyotl.api import PhylesystemAPI from peyotl.test.support import test_phylesystem_api_for_study from peyotl.test.support.pathmap import get_test_repos from peyotl.utility import get_logger _LOG = get_logger(__name__) test_repos = get_test_repos(['mini_phyl', 'mini_system']) @unittest.skipIf(not test_repos, 'See the documentation about the maintainers test to configure your ' 'machine to run tests that require the mini_phyl and mini_system repos') class TestPhylesystemAPI(unittest.TestCase): def setUp(self): self.pa = PhylesystemAPI(None, get_from='local', locals_repos_dict=test_repos) def testLocalStudyList(self): sl = self.pa.study_list # local repo should have just a few studies # @TODO we need a better test, I changed it from 10 to 10000. # because I use my own fork of a large phylesystem in my tests # I'm not sure what invariants we should check for, but # length of study list is probably not one. self.assertTrue(len(sl) < 10000) def testLocalSugar(self): test_phylesystem_api_for_study(self, self.pa, 'xy_10')
#! /usr/bin/env python # coding=utf-8 from peyotl.collections_store.collections_umbrella import _TreeCollectionStore import unittest from peyotl.test.support import pathmap import os from peyotl.utility import get_logger _LOG = get_logger(__name__) _repos = pathmap.get_test_repos() mc = _repos['mini_collections'] # TODO: filter repo list to just tree-collection shards? or rely on smart (failed) shard creation? # _repos = {'mini_collections': mc} @unittest.skipIf( not os.path.isdir(mc), 'Peyotl not configured for maintainer test of mini_collections.' 'Skipping this test is normal (for everyone other than maintainers).\n' 'See http://opentreeoflife.github.io/peyotl/maintainer/') class TestTreeCollections(unittest.TestCase): def setUp(self): self.r = dict(_repos) def testSlugify(self): from peyotl.utility.str_util import slugify self.assertEqual('simple-test', slugify('Simple Test')) self.assertEqual('no-punctuation-allowed',
from peyotl.phylesystem.git_workflows import acquire_lock_raise, \ commit_and_try_merge2master, \ delete_study, \ GitWorkflowError, \ merge_from_master from peyotl.phylesystem.phylesystem_umbrella import Phylesystem from peyotl.utility.input_output import read_as_json import unittest import codecs import json import copy from peyotl.test.support import pathmap from peyotl.utility import get_logger _LOG = get_logger(__name__) phylesystem = Phylesystem(pathmap.get_test_repos()) _MINI_PHYL_SHA1 = '2d59ab892ddb3d09d4b18c91470b8c1c4cca86dc' _SID = 'xy_10' _AUTH = { 'name': 'test_name', 'email': '*****@*****.**', 'login': '******', } class TestPhylesystemDel(unittest.TestCase): def testDelStudy(self): ga = phylesystem.create_git_action(_SID) ga.acquire_lock() try:
#! /usr/bin/env python import unittest from peyotl.api import TreeCollectionsAPI from peyotl.test.support import test_collections_api from peyotl.test.support.pathmap import get_test_repos from peyotl.utility import get_logger _LOG = get_logger(__name__) test_repos = get_test_repos(['mini_collections']) @unittest.skipIf( not test_repos, 'See the documentation about the maintainers test to configure your ' 'machine to run tests that require the mini_collections repos') class TestTreeCollectionsAPI(unittest.TestCase): def setUp(self): self.tca = TreeCollectionsAPI(None, get_from='local', locals_repos_dict=test_repos) def testCollectionList(self): cl = self.tca.collection_list # We assume there's always at least one collection. self.assertTrue(len(cl) > 0) def testLocalSugar(self): test_collections_api(self, self.tca)
from peyotl.phylesystem.git_workflows import acquire_lock_raise, \ commit_and_try_merge2master, \ delete_study, \ GitWorkflowError, \ merge_from_master from peyotl.phylesystem.phylesystem_umbrella import Phylesystem from peyotl.utility.input_output import read_as_json import unittest import codecs import json import copy from peyotl.test.support import pathmap from peyotl.utility import get_logger _LOG = get_logger(__name__) phylesystem = Phylesystem(pathmap.get_test_repos()) _MINI_PHYL_SHA1 = '2d59ab892ddb3d09d4b18c91470b8c1c4cca86dc' _SID = 'xy_10' _AUTH = { 'name': 'test_name', 'email': '*****@*****.**', 'login': '******', } class TestPhylesystem(unittest.TestCase): def xtestSimple(self): ga = phylesystem.create_git_action(_SID) ga.acquire_lock() try: curr, sha, wip_map = ga.return_study(_SID, return_WIP_map=True)
#! /usr/bin/env python import unittest from peyotl.api import TreeCollectionsAPI from peyotl.test.support import test_collections_api from peyotl.test.support.pathmap import get_test_repos from peyotl.utility import get_logger _LOG = get_logger(__name__) test_repos = get_test_repos(['mini_collections']) @unittest.skipIf(not test_repos, 'See the documentation about the maintainers test to configure your ' 'machine to run tests that require the mini_collections repos') class TestTreeCollectionsAPI(unittest.TestCase): def setUp(self): self.tca = TreeCollectionsAPI(None, get_from='local', locals_repos_dict=test_repos) def testCollectionList(self): cl = self.tca.collection_list # We assume there's always at least one collection. self.assertTrue(len(cl) > 0) def testLocalSugar(self): test_collections_api(self, self.tca) if __name__ == "__main__": unittest.main()
#! /usr/bin/env python # coding=utf-8 import unittest from peyotl.amendments.amendments_umbrella import _TaxonomicAmendmentStore from peyotl.test.support import pathmap from peyotl.utility import get_logger _LOG = get_logger(__name__) test_repos = pathmap.get_test_repos(['mini_amendments']) @unittest.skipIf(not test_repos, 'See the documentation about the maintainers test to configure your ' 'machine to run tests that require the mini_amendments repos') class TestTaxonomicAmendments(unittest.TestCase): def setUp(self): self.c = _TaxonomicAmendmentStore(repos_dict=dict(test_repos)) def testInit(self): self.assertEqual(1, len(self.c._shards)) def testAmendmentIndexing(self): k = list(self.c._doc2shard_map.keys()) k.sort() expected = ['additions-5000000-5000003'] # TODO: populate with more test data? self.assertEqual(k, expected) def testURL(self):
#! /usr/bin/env python import unittest from peyotl.api import TaxonomicAmendmentsAPI from peyotl.test.support import test_amendments_api from peyotl.test.support.pathmap import get_test_repos from peyotl.utility import get_logger _LOG = get_logger(__name__) test_repos = get_test_repos(['mini_amendments']) @unittest.skipIf(not test_repos, 'See the documentation about the maintainers test to configure your ' 'machine to run tests that require the mini_amendments repos') class TestTaxonomicAmendmentsAPI(unittest.TestCase): def setUp(self): self.taa = TaxonomicAmendmentsAPI(None, get_from='local', locals_repos_dict=test_repos) def testAmendmentList(self): al = self.taa.amendment_list # We assume there's always at least one amendment. self.assertTrue(len(al) > 0) def testLocalSugar(self): test_amendments_api(self, self.taa) if __name__ == "__main__": unittest.main()
#! /usr/bin/env python # put tests here that use local phylesystem # see http://opentreeoflife.github.io/peyotl/maintainer/ for setup from peyotl.utility.input_output import read_as_json from peyotl.phylesystem.phylesystem_umbrella import _Phylesystem import unittest from peyotl.test.support import pathmap import os from peyotl.utility import get_logger _LOG = get_logger(__name__) _repos = pathmap.get_test_repos() ms, mp = _repos['mini_system'], _repos['mini_phyl'] # TODO: filter repo list to just phylesystem shards? or rely on smart (failed) shard creation? # _repos = {s: _repos[s] for s in _repos if s in ('mini_system', 'mini_phyl',)} # pylint: disable=W0212 @unittest.skipIf((not os.path.isdir(ms)) or (not os.path.isdir(mp)), 'Peyotl not configured for maintainer test of mini_phyl/system.' 'Skipping this test is normal (for everyone other than MTH and EJBM).\n' 'See http://opentreeoflife.github.io/peyotl/maintainer/ ') class TestPhylesystem(unittest.TestCase): def setUp(self): self.r = dict(_repos)