Rev 1733: Add simple layout tests. in file:///data/jelmer/bzr-svn/trunk/

Jelmer Vernooij jelmer at samba.org
Sun Aug 31 15:14:51 BST 2008


At file:///data/jelmer/bzr-svn/trunk/

------------------------------------------------------------
revno: 1733
revision-id: jelmer at samba.org-20080831141447-nwp1xm5oll82vbno
parent: jelmer at samba.org-20080831134401-jg5muuclgc23jc8u
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Sun 2008-08-31 16:14:47 +0200
message:
  Add simple layout tests.
added:
  tests/test_layout.py           test_layout.py-20080831140344-mixj35u5n1qnephn-1
modified:
  layout.py                      layout.py-20080323165407-y9qw8nx4oykvoe1k-1
  mapping4.py                    mapping4.py-20080827182338-y4xzpsf43vyiwcir-1
  tests/__init__.py              __init__.py-20060508151940-e9f4d914801a2535
=== modified file 'layout.py'
--- a/layout.py	2008-08-31 13:35:18 +0000
+++ b/layout.py	2008-08-31 14:14:47 +0000
@@ -201,6 +201,9 @@
 
 class RootLayout(RepositoryLayout):
     """Layout where the root of the repository is a branch."""
+
+    def __init__(self):
+        pass
     
     def get_tag_path(self, name, project=""):
         """Return the path at which the tag with specified name should be found.

=== modified file 'mapping4.py'
--- a/mapping4.py	2008-08-31 13:35:18 +0000
+++ b/mapping4.py	2008-08-31 14:14:47 +0000
@@ -31,11 +31,19 @@
     upgrade_suffix = "-svn4"
     experimental = True
 
-    def __init__(self):
+    def __init__(self, layout=None):
         self.name = "v4"
+        self.layout = layout
         self.revprops = mapping.BzrSvnMappingRevProps()
         self.fileprops = mapping.BzrSvnMappingFileProps(self.name)
 
+    @classmethod
+    def from_repository(cls, repository, _hinted_branch_path=None):
+        if _hinted_branch_path == "":
+            return cls(layout.RootLayout())
+        else:
+            return cls(layout.TrunkLayout(repository))
+
     @staticmethod
     def supports_roundtripping():
         return True
@@ -145,4 +153,4 @@
             self.fileprops.import_revision(svn_revprops, fileprops, uuid, branch, revnum, rev)
 
     def get_mandated_layout(self, repository):
-        return layout.TrunkLayout(repository)
+        return self.layout

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2008-08-30 23:45:11 +0000
+++ b/tests/__init__.py	2008-08-31 14:14:47 +0000
@@ -322,6 +322,7 @@
             'test_errors',
             'test_fetch',
             'test_fileids', 
+            'test_layout',
             'test_log',
             'test_logwalker',
             'test_mapping',

=== added file 'tests/test_layout.py'
--- a/tests/test_layout.py	1970-01-01 00:00:00 +0000
+++ b/tests/test_layout.py	2008-08-31 14:14:47 +0000
@@ -0,0 +1,38 @@
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
+ 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from bzrlib.tests import TestCase
+from bzrlib.plugins.svn import layout
+
+
+class LayoutTests:
+
+    def test_get_tag_path(self):
+        path = self.layout.get_tag_path("foo", "")
+        if path is None:
+            return None
+        self.assertIsInstance(path, str)
+
+    def test_tag_path_is_tag(self):
+        path = self.layout.get_tag_path("foo", "")
+        if path is None:
+            return None
+        self.assertTrue(self.layout.is_tag(path))
+
+
+class RootLayoutTests(TestCase,LayoutTests):
+
+    def setUp(self):
+        self.layout = layout.RootLayout()




More information about the bazaar-commits mailing list