mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-30 01:38:55 +00:00
First sketch of HTTP testing infrastructure.
This commit is contained in:
parent
ddd2780bd2
commit
12cbf8a901
38
src/allmydata/test/test_storage_http.py
Normal file
38
src/allmydata/test/test_storage_http.py
Normal file
@ -0,0 +1,38 @@
|
||||
"""
|
||||
Tests for HTTP storage client + server.
|
||||
"""
|
||||
|
||||
from twisted.trial.unittest import TestCase
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
|
||||
from treq.testing import StubTreq
|
||||
from hyperlink import DecodedURL
|
||||
|
||||
from ..storage.server import StorageServer
|
||||
from ..storage.http_server import HTTPServer
|
||||
from ..storage.http_client import StorageClient
|
||||
|
||||
|
||||
class HTTPTests(TestCase):
|
||||
"""
|
||||
Tests of HTTP client talking to the HTTP server.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.storage_server = StorageServer(self.mktemp(), b"\x00" * 20)
|
||||
# TODO what should the swissnum _actually_ be?
|
||||
self._http_server = HTTPServer(self._storage_server, b"abcd")
|
||||
self.client = StorageClient(
|
||||
DecodedURL.from_text("http://example.com"),
|
||||
b"abcd",
|
||||
treq=StubTreq(self._http_server.get_resource()),
|
||||
)
|
||||
|
||||
@inlineCallbacks
|
||||
def test_version(self):
|
||||
"""
|
||||
The client can return the version.
|
||||
"""
|
||||
version = yield self.client.get_version()
|
||||
expected_version = self.storage_server.remote_get_version()
|
||||
self.assertEqual(version, expected_version)
|
Loading…
Reference in New Issue
Block a user