From 739b81d5bee95362f710dead08486030a0e14d5c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 13 Nov 2019 14:28:50 -0500 Subject: [PATCH] Verify that token-count appears properly in the web interface --- .../tests/test_client_resource.py | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/_zkapauthorizer/tests/test_client_resource.py b/src/_zkapauthorizer/tests/test_client_resource.py index e816998..f810984 100644 --- a/src/_zkapauthorizer/tests/test_client_resource.py +++ b/src/_zkapauthorizer/tests/test_client_resource.py @@ -54,6 +54,7 @@ from testtools.matchers import ( ContainsDict, AfterPreprocessing, Equals, + NotEquals, Always, GreaterThan, ) @@ -648,6 +649,10 @@ class VoucherTests(TestCase): ).decode("utf-8"), ).encode("ascii"), ) + if redeemed: + token_count_comparison = NotEquals + else: + token_count_comparison = Equals self.assertThat( getting, @@ -655,13 +660,17 @@ class VoucherTests(TestCase): MatchesAll( ok_response(headers=application_json()), AfterPreprocessing( - json_content, + readBody, succeeded( - Equals(Voucher( - voucher, - created=now, - redeemed=redeemed, - ).marshal()), + AfterPreprocessing( + Voucher.from_json, + MatchesStructure( + number=Equals(voucher), + created=Equals(now), + redeemed=Equals(redeemed), + token_count=token_count_comparison(None), + ), + ), ), ), ), @@ -721,6 +730,10 @@ class VoucherTests(TestCase): voucher, created=now, redeemed=True, + # Value duplicated from + # PaymentController.redeem default. + # Should do this better. + token_count=100, ).marshal() for voucher in vouchers -- GitLab