diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 18:48:15 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 18:48:15 +0100 |
commit | a907be75dca2d0ca7adac0a025432cbe4eb2e529 (patch) | |
tree | 905603c1a60763055d77ca4e0257f4e1edeb78c7 /morphlib/morphologyfactory_tests.py | |
parent | 3525f81ecea60f53d3ef842c1e11c4cab1538511 (diff) | |
download | morph-a907be75dca2d0ca7adac0a025432cbe4eb2e529.tar.gz |
Always ls-tree before trying to cat-file
This provides much better performance in cases where most of the
repos do not have a .morph included.
Diffstat (limited to 'morphlib/morphologyfactory_tests.py')
-rw-r--r-- | morphlib/morphologyfactory_tests.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 9d6900d7..8b69f1de 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -90,7 +90,7 @@ class FakeLocalRepo(object): return 'text' def ls_tree(self, sha1): - return [] + return self.morphologies.keys() class FakeLocalRepoCache(object): @@ -119,6 +119,9 @@ class MorphologyFactoryTests(unittest.TestCase): def noremotefile(self, *args): raise CatFileError('reponame', 'ref', 'filename') + def localmorph(self, *args): + return ['foo.morph'] + def nolocalmorph(self, *args): if args[-1].endswith('.morph'): raise IOError('File not found') @@ -127,6 +130,9 @@ class MorphologyFactoryTests(unittest.TestCase): def autotoolsbuildsystem(self, *args): return ['configure.in'] + def remotemorph(self, *args): + return ['foo.morph'] + def noremotemorph(self, *args): if args[-1].endswith('.morph'): raise CatFileError('reponame', 'ref', 'filename') @@ -136,11 +142,13 @@ class MorphologyFactoryTests(unittest.TestCase): return False def test_gets_morph_from_local_repo(self): + self.lr.ls_tree = self.localmorph morph = self.mf.get_morphology('reponame', 'sha1', 'foo.morph') self.assertEqual('local-foo', morph['name']) def test_gets_morph_from_remote_repo(self): + self.rrc.ls_tree = self.remotemorph self.lrc.has_repo = self.doesnothaverepo morph = self.mf.get_morphology('reponame', 'sha1', 'foo.morph') @@ -174,6 +182,7 @@ class MorphologyFactoryTests(unittest.TestCase): 'reponame', 'sha1', 'unreached.morph') def test_looks_locally_with_no_remote(self): + self.lr.ls_tree = self.localmorph morph = self.lmf.get_morphology('reponame', 'sha1', 'foo.morph') self.assertEqual('local-foo', morph['name']) |