Skip to content
Snippets Groups Projects

Fix bugs in test_reachable

Merged Jean-Paul Calderone requested to merge test_reachable-broken into main
1 file
+ 32
16
Compare changes
  • Side-by-side
  • Inline
@@ -58,6 +58,7 @@ from testtools.matchers import (
@@ -58,6 +58,7 @@ from testtools.matchers import (
MatchesAll,
MatchesAll,
MatchesAny,
MatchesAny,
MatchesStructure,
MatchesStructure,
 
Not,
)
)
from testtools.twistedsupport import CaptureTwistedLogs, succeeded
from testtools.twistedsupport import CaptureTwistedLogs, succeeded
from treq.testing import RequestTraversalAgent
from treq.testing import RequestTraversalAgent
@@ -66,7 +67,6 @@ from twisted.python.filepath import FilePath
@@ -66,7 +67,6 @@ from twisted.python.filepath import FilePath
from twisted.web.client import FileBodyProducer, readBody
from twisted.web.client import FileBodyProducer, readBody
from twisted.web.http import BAD_REQUEST, NOT_FOUND, NOT_IMPLEMENTED, OK, UNAUTHORIZED
from twisted.web.http import BAD_REQUEST, NOT_FOUND, NOT_IMPLEMENTED, OK, UNAUTHORIZED
from twisted.web.http_headers import Headers
from twisted.web.http_headers import Headers
from twisted.web.resource import IResource, getChildForRequest
from .. import NAME
from .. import NAME
from .. import __file__ as package_init_file
from .. import __file__ as package_init_file
@@ -92,7 +92,7 @@ from ..storage_common import (
@@ -92,7 +92,7 @@ from ..storage_common import (
required_passes,
required_passes,
)
)
from .json import loads
from .json import loads
from .matchers import Provides, between, matches_response
from .matchers import between, matches_response
from .strategies import (
from .strategies import (
api_auth_tokens,
api_auth_tokens,
client_doublespendredeemer_configurations,
client_doublespendredeemer_configurations,
@@ -103,7 +103,6 @@ from .strategies import (
@@ -103,7 +103,6 @@ from .strategies import (
direct_tahoe_configs,
direct_tahoe_configs,
posix_timestamps,
posix_timestamps,
request_paths,
request_paths,
requests,
share_parameters,
share_parameters,
tahoe_configs,
tahoe_configs,
vouchers,
vouchers,
@@ -402,27 +401,44 @@ class ResourceTests(TestCase):
@@ -402,27 +401,44 @@ class ResourceTests(TestCase):
@given(
@given(
tahoe_configs(),
tahoe_configs(),
requests(
sampled_from(
sampled_from(
[
[
[b"voucher"],
[b"unblinded-token"],
[b"version"],
[b"voucher"],
]
[b"version"],
]
)
),
),
 
api_auth_tokens(),
)
)
def test_reachable(self, get_config, request):
def test_reachable(self, get_config, request_path, api_auth_token):
"""
"""
A resource is reachable at a child of the resource returned by
A resource is reachable at a child of the resource returned by
``from_configuration``.
``from_configuration``.
"""
"""
tempdir = self.useFixture(TempDir())
config = get_config_with_api_token(
config = get_config(tempdir.join("tahoe"), "tub.port")
self.useFixture(TempDir()),
 
get_config,
 
api_auth_token,
 
)
root = root_from_config(config, datetime.now)
root = root_from_config(config, datetime.now)
 
agent = RequestTraversalAgent(root)
 
requesting = authorized_request(
 
api_auth_token,
 
agent,
 
b"GET",
 
b"http://127.0.0.1/" + b"/".join(request_path),
 
)
 
 
matches_status = matches_response(
 
code_matcher=Not(
 
MatchesAny(
 
Equals(404),
 
between(500, 599),
 
)
 
),
 
)
self.assertThat(
self.assertThat(
getChildForRequest(root, request),
requesting,
Provides([IResource]),
succeeded(matches_status),
)
)
@given(
@given(
Loading