summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo_tests.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-10-02 14:58:48 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-10-03 14:40:37 +0100
commit9c2ccea87da3809082a1fa392611cc5294f717fe (patch)
treea9aecb9a4d234a45ea1de0976ab8eedac6cf19fd /morphlib/cachedrepo_tests.py
parent8bcb622e182d49d143af417bd3d0a64d4188356b (diff)
downloadmorph-9c2ccea87da3809082a1fa392611cc5294f717fe.tar.gz
Use repository cache for git access other than current system branch
The origin/ refs in the system branch checkout repos may or may not be up to date, and may or may not have been tampered with by the user. Much better to use our central cache for everything other than changes to the system branch ref itself, where we should indeed be honouring the user's local changes. At a later date we could warn if the user modifies refs other than the system branch ref but does not push, as these changes will have no effect. NOTE: this commit breaks 'morph merge'. It is fixed in the next commit.
Diffstat (limited to 'morphlib/cachedrepo_tests.py')
-rw-r--r--morphlib/cachedrepo_tests.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py
index 0a87b32a..0ca0882f 100644
--- a/morphlib/cachedrepo_tests.py
+++ b/morphlib/cachedrepo_tests.py
@@ -26,6 +26,11 @@ from morphlib import cachedrepo
class CachedRepoTests(unittest.TestCase):
+ EXAMPLE_MORPH = '''{
+ "name": "foo",
+ "kind": "chunk"
+ }'''
+
def show_ref(self, ref):
output = {
'master':
@@ -57,6 +62,7 @@ class CachedRepoTests(unittest.TestCase):
def rev_list(self, ref):
output = {
+ 'master': 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9':
'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
'a4da32f5a81c8bc6d660404724cedc3bc0914a75':
@@ -70,7 +76,7 @@ class CachedRepoTests(unittest.TestCase):
def cat_file(self, ref, filename):
output = {
'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9:foo.morph':
- 'contents of foo.morph'
+ self.EXAMPLE_MORPH
}
try:
return output['%s:%s' % (ref, filename)]
@@ -165,7 +171,7 @@ class CachedRepoTests(unittest.TestCase):
def test_cat_existing_file_in_existing_ref(self):
data = self.repo.cat('e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
'foo.morph')
- self.assertEqual(data, 'contents of foo.morph')
+ self.assertEqual(data, self.EXAMPLE_MORPH)
def test_fail_cat_file_in_invalid_ref(self):
self.assertRaises(cachedrepo.InvalidReferenceError, self.repo.cat,
@@ -216,6 +222,10 @@ class CachedRepoTests(unittest.TestCase):
morph_filename = os.path.join(unpack_dir, 'foo.morph')
self.assertTrue(os.path.exists(morph_filename))
+ def test_load_morphology_from_existing_ref(self):
+ morph = self.repo.load_morphology('master', 'foo')
+ self.assertTrue(morph['name'] == 'foo')
+
def test_ls_tree_in_existing_ref(self):
data = self.repo.ls_tree('e28a23812eadf2fce6583b8819b9c5dbd36b9fb9')
self.assertEqual(data, ['foo.morph'])