diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-10-23 17:33:49 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-12-03 10:23:27 +0000 |
commit | 2dc11594d5b95d876c9997ca40dfb08bf06c830b (patch) | |
tree | c2752f38b17e765416dad9ea64688aad0e60d60a /morphlib/localrepocache_tests.py | |
parent | bb1960c7711a8a48bbaabd188158a3c5d7f0ff04 (diff) | |
download | morph-2dc11594d5b95d876c9997ca40dfb08bf06c830b.tar.gz |
Rework CachedRepo to use the GitDirectory class where possible
This consolidates a bunch of code paths that were previously duplicated.
This also changes the API for local cached repos to match the
function names GitDirectory uses. Note that the remote repo cache still
uses the old names, and should be fixed when time permits.
Some unit tests that use the CachedRepo module required a bit of
inelegant monkey-patching in order that they continue to work. A better
way to do this would be with the 'mock' library (which would need to be
added to Baserock 'build' and 'devel' systems before we could use it).
Diffstat (limited to 'morphlib/localrepocache_tests.py')
-rw-r--r-- | morphlib/localrepocache_tests.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/morphlib/localrepocache_tests.py b/morphlib/localrepocache_tests.py index 3cc4f07f..ab6e71fd 100644 --- a/morphlib/localrepocache_tests.py +++ b/morphlib/localrepocache_tests.py @@ -22,6 +22,7 @@ import cliapp import fs.memoryfs import morphlib +import morphlib.gitdir_tests class FakeApplication(object): @@ -56,6 +57,7 @@ class LocalRepoCacheTests(unittest.TestCase): self.lrc._git = self.fake_git self.lrc._fetch = self.not_found self.lrc._mkdtemp = self.fake_mkdtemp + self.lrc._new_cached_repo_instance = self.new_cached_repo_instance self._mkdtemp_count = 0 def fake_git(self, args, **kwargs): @@ -86,6 +88,11 @@ class LocalRepoCacheTests(unittest.TestCase): self.lrc.fs.makedir(dirname+"/"+thing) return thing + def new_cached_repo_instance(self, *args): + with morphlib.gitdir_tests.allow_nonexistant_git_repos(): + return morphlib.cachedrepo.CachedRepo( + FakeApplication(), *args) + def not_found(self, url, path): raise cliapp.AppException('Not found') |