summaryrefslogtreecommitdiff
path: root/morphlib/sourceresolver_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/sourceresolver_tests.py')
-rw-r--r--morphlib/sourceresolver_tests.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/morphlib/sourceresolver_tests.py b/morphlib/sourceresolver_tests.py
index 2410218a..6d6a83fa 100644
--- a/morphlib/sourceresolver_tests.py
+++ b/morphlib/sourceresolver_tests.py
@@ -24,7 +24,7 @@ from morphlib.sourceresolver import (SourceResolver,
PickleCacheManager,
MorphologyNotFoundError,
NotcachedError)
-from morphlib.remoterepocache import CatFileError
+from morphlib.remoterepocache import CatFileError, LsTreeError
class FakeRemoteRepoCache(object):
@@ -135,6 +135,9 @@ class FakeLocalRepo(object):
def list_files(self, ref, recurse):
return self.morphologies.keys()
+ def update(self):
+ pass
+
class FakeLocalRepoCache(object):
@@ -147,6 +150,9 @@ class FakeLocalRepoCache(object):
def get_repo(self, reponame):
return self.lr
+ def cache_repo(self, reponame):
+ return self.lr
+
class SourceResolverTests(unittest.TestCase):
@@ -188,6 +194,9 @@ class SourceResolverTests(unittest.TestCase):
def noremotefile(self, *args):
raise CatFileError('reponame', 'ref', 'filename')
+ def noremoterepo(self, *args):
+ raise LsTreeError('reponame', 'ref')
+
def localmorph(self, *args):
return ['chunk.morph']
@@ -241,6 +250,15 @@ class SourceResolverTests(unittest.TestCase):
'assumed-local.morph')
self.assertEqual('autotools', name)
+ def test_cache_repo_if_not_in_either_cache(self):
+ self.lrc.has_repo = self.doesnothaverepo
+ self.lr.read_file = self.nolocalmorph
+ self.lr.list_files = self.autotoolsbuildsystem
+ self.rrc.ls_tree = self.noremoterepo
+ name = self.sr._detect_build_system('reponame', 'sha1',
+ 'assumed-local.morph')
+ self.assertEqual('autotools', name)
+
def test_autodetects_remote_morphology(self):
self.lrc.has_repo = self.doesnothaverepo
self.rrc.cat_file = self.noremotemorph
@@ -262,7 +280,8 @@ class SourceResolverTests(unittest.TestCase):
def test_raises_error_when_repo_does_not_exist(self):
self.lrc.has_repo = self.doesnothaverepo
- self.assertRaises(NotcachedError, self.lsr._detect_build_system,
+ self.assertRaises(MorphologyNotFoundError,
+ self.lsr._detect_build_system,
'reponame', 'sha1', 'non-existent.morph')
def test_raises_error_when_failed_to_detect_build_system(self):