dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00173
[PATCH 7/7] Compat tests for servers with and without side-band-64k.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Change-Id: I0b4c2766f866e7f1030bd75b7e187ee02be894a6
---
NEWS | 2 ++
dulwich/tests/compat/server_utils.py | 15 +++++++++++++++
dulwich/tests/compat/test_server.py | 34 ++++++++++++++++++++++++++++++++--
dulwich/tests/compat/test_web.py | 33 +++++++++++++++++++++++++++++++--
4 files changed, 80 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index 53ce602..603d8da 100644
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,8 @@
* More flexible version checking for compat tests. (Dave Borowitz)
+ * Compat tests for servers with and without side-band-64k. (Dave Borowitz)
+
CLEANUP
* Clean up file headers. (Dave Borowitz)
diff --git a/dulwich/tests/compat/server_utils.py b/dulwich/tests/compat/server_utils.py
index 8659b64..37000c4 100644
--- a/dulwich/tests/compat/server_utils.py
+++ b/dulwich/tests/compat/server_utils.py
@@ -24,6 +24,9 @@ import select
import socket
import threading
+from dulwich.server import (
+ ReceivePackHandler,
+ )
from dulwich.tests.utils import (
tear_down_repo,
)
@@ -155,3 +158,15 @@ class ShutdownServerMixIn:
except:
self.handle_error(request, client_address)
self.close_request(request)
+
+
+# TODO(dborowitz): Come up with a better way of testing various permutations of
+# capabilities. The only reason it is the way it is now is that side-band-64k
+# was only recently introduced into git-receive-pack.
+class NoSideBand64kReceivePackHandler(ReceivePackHandler):
+ """ReceivePackHandler that does not support side-band-64k."""
+
+ @classmethod
+ def capabilities(cls):
+ return tuple(c for c in ReceivePackHandler.capabilities()
+ if c != 'side-band-64k')
diff --git a/dulwich/tests/compat/test_server.py b/dulwich/tests/compat/test_server.py
index 7659ba5..9d236c3 100644
--- a/dulwich/tests/compat/test_server.py
+++ b/dulwich/tests/compat/test_server.py
@@ -29,10 +29,12 @@ import threading
from dulwich.server import (
DictBackend,
TCPGitServer,
+ ReceivePackHandler,
)
from server_utils import (
ServerTests,
ShutdownServerMixIn,
+ NoSideBand64kReceivePackHandler,
)
from utils import (
CompatTestCase,
@@ -54,7 +56,10 @@ if not getattr(TCPGitServer, 'shutdown', None):
class GitServerTestCase(ServerTests, CompatTestCase):
- """Tests for client/server compatibility."""
+ """Tests for client/server compatibility.
+
+ This server test case does not use side-band-64k in git-receive-pack.
+ """
protocol = 'git'
@@ -66,10 +71,35 @@ class GitServerTestCase(ServerTests, CompatTestCase):
ServerTests.tearDown(self)
CompatTestCase.tearDown(self)
+ def _handlers(self):
+ return {'git-receive-pack': NoSideBand64kReceivePackHandler}
+
+ def _check_server(self, dul_server):
+ receive_pack_handler_cls = dul_server.handlers['git-receive-pack']
+ caps = receive_pack_handler_cls.capabilities()
+ self.assertFalse('side-band-64k' in caps)
+
def _start_server(self, repo):
backend = DictBackend({'/': repo})
- dul_server = TCPGitServer(backend, 'localhost', 0)
+ dul_server = TCPGitServer(backend, 'localhost', 0,
+ handlers=self._handlers())
+ self._check_server(dul_server)
threading.Thread(target=dul_server.serve).start()
self._server = dul_server
_, port = self._server.socket.getsockname()
return port
+
+
+class GitServerSideBand64kTestCase(GitServerTestCase):
+ """Tests for client/server compatibility with side-band-64k support."""
+
+ # side-band-64k in git-receive-pack was introduced in git 1.7.0.2
+ min_git_version = (1, 7, 0, 2)
+
+ def _handlers(self):
+ return None # default handlers include side-band-64k
+
+ def _check_server(self, server):
+ receive_pack_handler_cls = server.handlers['git-receive-pack']
+ caps = receive_pack_handler_cls.capabilities()
+ self.assertTrue('side-band-64k' in caps)
diff --git a/dulwich/tests/compat/test_web.py b/dulwich/tests/compat/test_web.py
index 2c228d4..d1593db 100644
--- a/dulwich/tests/compat/test_web.py
+++ b/dulwich/tests/compat/test_web.py
@@ -42,6 +42,7 @@ from dulwich.web import (
from server_utils import (
ServerTests,
ShutdownServerMixIn,
+ NoSideBand64kReceivePackHandler,
)
from utils import (
CompatTestCase,
@@ -84,7 +85,10 @@ class WebTests(ServerTests):
class SmartWebTestCase(WebTests, CompatTestCase):
- """Test cases for smart HTTP server."""
+ """Test cases for smart HTTP server.
+
+ This server test case does not use side-band-64k in git-receive-pack.
+ """
min_git_version = (1, 6, 6)
@@ -96,8 +100,33 @@ class SmartWebTestCase(WebTests, CompatTestCase):
WebTests.tearDown(self)
CompatTestCase.tearDown(self)
+ def _handlers(self):
+ return {'git-receive-pack': NoSideBand64kReceivePackHandler}
+
+ def _check_app(self, app):
+ receive_pack_handler_cls = app.handlers['git-receive-pack']
+ caps = receive_pack_handler_cls.capabilities()
+ self.assertFalse('side-band-64k' in caps)
+
def _make_app(self, backend):
- return HTTPGitApplication(backend)
+ app = HTTPGitApplication(backend, handlers=self._handlers())
+ self._check_app(app)
+ return app
+
+
+class SmartWebSideBand64kTestCase(SmartWebTestCase):
+ """Test cases for smart HTTP server with side-band-64k support."""
+
+ # side-band-64k in git-receive-pack was introduced in git 1.7.0.2
+ min_git_version = (1, 7, 0, 2)
+
+ def _handlers(self):
+ return None # default handlers include side-band-64k
+
+ def _check_app(self, app):
+ receive_pack_handler_cls = app.handlers['git-receive-pack']
+ caps = receive_pack_handler_cls.capabilities()
+ self.assertTrue('side-band-64k' in caps)
class DumbWebTestCase(WebTests, CompatTestCase):
--
1.7.1
References