Rev 8: Add tests for server code. in file:///home/jelmer/bzr/bzrsvnserve/

Jelmer Vernooij jelmer at samba.org
Mon Jan 22 12:58:46 GMT 2007


------------------------------------------------------------
revno: 8
revision-id: jelmer at samba.org-20070122125840-sib4iysnuz238g2k
parent: jelmer at samba.org-20070122114454-s6kqpgg5k3fl0dtf
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzrsvnserve
timestamp: Mon 2007-01-22 13:58:40 +0100
message:
  Add tests for server code.
added:
  tests/test_server.py           test_server.py-20070122114402-zcwhr4cxc67jvakf-1
modified:
  __init__.py                    __init__.py-20061015145107-e1erl7tzb3zk831k-1
  marshall.py                    marshall.py-20070122110546-ggdrkocyus0pjsqd-1
  svnserver.py                   svnserver.py-20061015150253-0jjovnw1ax00rjlb-1
  tests/__init__.py              __init__.py-20070122111740-cibkqznxtxxbyvjt-1
  tests/test_marshall.py         test_marshall.py-20070122110633-944cvow1y1hg6krp-1
=== added file 'tests/test_server.py'
--- a/tests/test_server.py	1970-01-01 00:00:00 +0000
+++ b/tests/test_server.py	2007-01-22 12:58:40 +0000
@@ -0,0 +1,37 @@
+# Copyright (C) 2006-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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+from bzrlib.branch import Branch
+from bzrlib.tests import TestCaseInTempDir
+from marshall import literal, MarshallError, marshall, unmarshall
+from svnserver import SVNServer
+
+from cStringIO import StringIO
+import os
+
+class TestServer(TestCaseInTempDir):
+    def setUp(self):
+        super(TestServer, self).setUp()
+        self.branch_path = os.path.join(self.test_dir, 'a')
+        self.branch = Branch.initialize(self.branch_path)
+        self.outstr = StringIO()
+        self.server = SVNServer(self.branch_path, None, self.outstr)
+
+    def test_send_greeting(self):
+        self.server.send_greeting()
+        self.outstr.seek(0)
+        self.assertEqual("( success ( 1 2 ( ANONYMOUS ) ( edit-pipeline ) ) ) ",
+                         self.outstr.read())

=== modified file '__init__.py'
--- a/__init__.py	2007-01-22 11:38:53 +0000
+++ b/__init__.py	2007-01-22 12:58:40 +0000
@@ -61,3 +61,12 @@
     return result
 
 sys.path.append(os.path.dirname(__file__))
+
+try:
+    import uuid
+except:
+    from bzrlib.errors import BzrError
+    from bzrlib.trace import warning
+    warning('uuid module not available, disabling svnserve plugin')
+    raise BzrError('uuid module not available')
+

=== modified file 'marshall.py'
--- a/marshall.py	2007-01-22 11:38:53 +0000
+++ b/marshall.py	2007-01-22 12:58:40 +0000
@@ -55,6 +55,8 @@
 
 def unmarshall(x):
     whitespace = ['\n', ' ']
+    if len(x) == 0:
+        raise MarshallError("Not enough data")
     if x[0] == "(" and x[1] == " ": # list follows
         x = x[2:]
         ret = []

=== modified file 'svnserver.py'
--- a/svnserver.py	2007-01-22 11:44:54 +0000
+++ b/svnserver.py	2007-01-22 12:58:40 +0000
@@ -19,7 +19,7 @@
 
 import os
 
-from marshall import marshall, unmarshall
+from marshall import marshall, unmarshall, literal
 
 class SVNServer:
     def __init__(self, rootdir, instr, outstr):
@@ -50,7 +50,7 @@
     commands = {
             "get-latest-rev": get_latest_rev,
             "log": log,
-            reparent: reparent,
+            "reparent": reparent,
             # FIXME: get-dated-rev
             # FIXME: rev-proplist
             # FIXME: rev-prop

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2007-01-22 11:38:53 +0000
+++ b/tests/__init__.py	2007-01-22 12:58:40 +0000
@@ -20,7 +20,8 @@
     loader = TestUtil.TestLoader()
     suite = TestSuite()
     testmod_names = [
-            'test_marshall'
+            'test_marshall',
+            'test_server'
             ]
     suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i) for i in testmod_names]))
 

=== modified file 'tests/test_marshall.py'
--- a/tests/test_marshall.py	2007-01-22 11:38:53 +0000
+++ b/tests/test_marshall.py	2007-01-22 12:58:40 +0000
@@ -66,6 +66,9 @@
     def test_unmarshall_literal(self):
         self.assertEqual(('', literal("x")), unmarshall("x "))
 
+    def test_unmarshall_empty(self):
+        self.assertRaises(MarshallError, unmarshall, "")
+
     def test_unmarshall_nospace(self):
         self.assertRaises(MarshallError, unmarshall, "nospace")
 




More information about the bazaar-commits mailing list