Skip to content
Snippets Groups Projects
Unverified Commit 52bd8bae authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Test the non-None case of lease maintenance spending activity API

parent a1fedb6b
No related branches found
No related tags found
1 merge request!81Add web interface for lease maintenance activity monitoring
......@@ -162,7 +162,7 @@ class _UnblindedTokenCollection(Resource):
if activity is None:
return activity
return {
u"when": activity.finished,
u"when": activity.finished.isoformat(),
u"count": activity.passes_required,
}
......
......@@ -440,6 +440,50 @@ class UnblindedTokenTests(TestCase):
),
)
@given(
tahoe_configs(),
lists(
lists(
integers(min_value=0),
min_size=1,
),
),
datetimes(),
)
def test_latest_lease_maintenance_spending(self, get_config, size_observations, now):
"""
The most recently completed record of lease maintenance spending activity
is reported in the response to a **GET** request.
"""
tempdir = self.useFixture(TempDir())
config = get_config(tempdir.join(b"tahoe"), b"tub.port")
root = root_from_config(config, lambda: now)
# Put some activity into it.
total = 0
activity = root.store.start_lease_maintenance()
for sizes in size_observations:
total += sum(sizes)
activity.observe(sizes)
activity.finish()
agent = RequestTraversalAgent(root)
d = agent.request(
b"GET",
b"http://127.0.0.1/unblinded-token",
)
d.addCallback(readBody)
d.addCallback(
lambda body: loads(body)[u"lease-maintenance-spending"],
)
self.assertThat(
d,
succeeded(Equals({
"when": now.isoformat(),
"count": total,
})),
)
def succeeded_with_unblinded_tokens_with_matcher(
all_token_count,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment