mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
Add a test for persistent state and make it pass
This commit is contained in:
parent
8e6aeb49e0
commit
1fef619819
@ -2,6 +2,7 @@ import hashlib
|
||||
from mock import Mock
|
||||
from json import (
|
||||
dumps,
|
||||
loads,
|
||||
)
|
||||
from fixtures import (
|
||||
TempDir,
|
||||
@ -459,6 +460,26 @@ class StoragePluginWebPresence(AsyncTestCase):
|
||||
result = yield do_http(b"get", url)
|
||||
self.assertThat(result, Equals(dumps({b"web": b"1"})))
|
||||
|
||||
@inlineCallbacks
|
||||
def test_plugin_resource_persistent_across_requests(self):
|
||||
"""
|
||||
The plugin's resource is loaded and then saved and re-used for future
|
||||
requests.
|
||||
"""
|
||||
url = u"http://127.0.0.1:{port}/storage-plugins/{plugin_name}/counter".format(
|
||||
port=self.port,
|
||||
plugin_name=self.storage_plugin,
|
||||
).encode("utf-8")
|
||||
values = {
|
||||
loads((yield do_http(b"get", url)))[u"value"],
|
||||
loads((yield do_http(b"get", url)))[u"value"],
|
||||
}
|
||||
self.assertThat(
|
||||
values,
|
||||
# If the counter manages to go up then the state stuck around.
|
||||
Equals({1, 2}),
|
||||
)
|
||||
|
||||
|
||||
def make_broker(tub_maker=lambda h: Mock()):
|
||||
"""
|
||||
|
@ -29,6 +29,8 @@ class StoragePlugins(Resource, object):
|
||||
"""
|
||||
resources = self._client.get_client_storage_plugin_web_resources()
|
||||
try:
|
||||
return resources[segment]
|
||||
result = resources[segment]
|
||||
except KeyError:
|
||||
return NoResource()
|
||||
result = NoResource()
|
||||
self.putChild(segment, result)
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user