diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 17:57:49 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 17:57:49 +0100 |
commit | 975b3f30605c36a714bf5b9619817a897cb6a4a3 (patch) | |
tree | 5564243efa6a55dc49ed05c2455e70b32598c6bf /morphlib/remoterepocache_tests.py | |
parent | 6c13c2ebdea1da19bf359fef9a9e0b08e5491a4a (diff) | |
download | morph-975b3f30605c36a714bf5b9619817a897cb6a4a3.tar.gz |
Support 'git ls-tree' in local and remote repos
Diffstat (limited to 'morphlib/remoterepocache_tests.py')
-rw-r--r-- | morphlib/remoterepocache_tests.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/morphlib/remoterepocache_tests.py b/morphlib/remoterepocache_tests.py index 6f162f7d..5ef61f48 100644 --- a/morphlib/remoterepocache_tests.py +++ b/morphlib/remoterepocache_tests.py @@ -14,6 +14,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import json import unittest import morphlib @@ -27,6 +28,13 @@ class RemoteRepoCacheTests(unittest.TestCase): def _cat_file_for_repo_url(self, repo_url, sha1, filename): return self.files[repo_url][sha1][filename] + def _ls_tree_for_repo_url(self, repo_url, sha1): + return json.dumps({ + 'repo': repo_url, + 'ref': sha1, + 'tree': self.files[repo_url][sha1] + }) + def setUp(self): self.sha1s = { 'git://gitorious.org/baserock/morph': { @@ -50,6 +58,7 @@ class RemoteRepoCacheTests(unittest.TestCase): self.server_url, resolver) self.cache._resolve_ref_for_repo_url = self._resolve_ref_for_repo_url self.cache._cat_file_for_repo_url = self._cat_file_for_repo_url + self.cache._ls_tree_for_repo_url = self._ls_tree_for_repo_url def test_sets_server_url(self): self.assertEqual(self.cache.server_url, self.server_url) @@ -103,3 +112,22 @@ class RemoteRepoCacheTests(unittest.TestCase): self.cache.cat_file, 'non-existent-repo', 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9', 'some-file') + + def test_ls_tree_in_existing_repo_and_ref(self): + content = self.cache.ls_tree( + 'upstream:linux', 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9') + self.assertEqual(content, ['linux.morph']) + + def test_fail_ls_tree_using_invalid_sha1(self): + self.assertRaises(morphlib.remoterepocache.LsTreeError, + self.cache.ls_tree, 'upstream:linux', 'blablabla') + + def test_fail_ls_file_in_non_existent_ref_in_existing_repo(self): + self.assertRaises(morphlib.remoterepocache.LsTreeError, + self.cache.ls_tree, 'upstream:linux', + 'ecd7a325095a0d19b8c3d76f578d85b979461d41') + + def test_fail_ls_tree_in_non_existent_repo(self): + self.assertRaises(morphlib.remoterepocache.LsTreeError, + self.cache.ls_tree, 'non-existent-repo', + 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9') |