From 654f088bab35aff16cd999a5744b8f045e2cc49b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 10 Mar 2019 14:40:14 +0200 Subject: Add: Delete members --- yarns/000.yarn | 37 +++++++++++++++++++++++++++++-------- yarns/lib.py | 3 +++ 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'yarns') diff --git a/yarns/000.yarn b/yarns/000.yarn index adff964..79e398d 100644 --- a/yarns/000.yarn +++ b/yarns/000.yarn @@ -33,17 +33,20 @@ Examples will be provided. ## Manage memberships -This section shows the API calls to manage a memberhip: to create the -member, to update and retrieve it, and to search memberships. +This section shows the API calls to manage a memberhip. SCENARIO Manage memberships GIVEN An effiapi instance +First make sure the register is empty. + WHEN admin requests GET /status THEN HTTP status is 200 AND body matches { "resources": 0 } +Create a member. + WHEN admin requests POST /memb with body { "fullname": "James Bond" } THEN HTTP status is 201 AND remember header Muck-Id as ID @@ -58,6 +61,8 @@ member, to update and retrieve it, and to search memberships. AND body matches { "fullname": "James Bond" } AND header Muck-Revision is ${REV1} +Update the member. + WHEN admin requests PUT /memb with id ${ID}, revision ${REV1}, ... and body { "fullname": "Alfred Pennyworth" } THEN HTTP status is 200 @@ -68,12 +73,24 @@ member, to update and retrieve it, and to search memberships. AND body matches { "fullname": "Alfred Pennyworth" } AND header Muck-Revision is ${REV2} +Delete the member. + + WHEN admin requests DELETE /memb with id ${ID} + THEN HTTP status is 200 + + WHEN admin requests GET /status + THEN HTTP status is 200 + AND body matches { "resources": 0 } + + WHEN admin requests GET /memb with header Muck-Id: ${ID} + THEN HTTP status is 404 + +Done. + FINALLY Effiapi is terminated TODO: -* update -* delete * search * members can see their own data, and can't see each others' * member follows authn link emailed to them @@ -119,12 +136,16 @@ TODO: headers = { header: value, } - V['xx'] = { - 'header': header, - 'value': value, - } effiapi.GET('/memb', headers, None) + IMPLEMENTS WHEN admin requests DELETE /memb with id (\S+) + rid = get_expanded_match() + print('rid', repr(rid)) + headers = { + 'Muck-id': rid, + } + effiapi.DELETE('/memb', headers, None) + ## Inspect HTTP responses IMPLEMENTS THEN HTTP status is (\d+) diff --git a/yarns/lib.py b/yarns/lib.py index 100511e..2e76b88 100644 --- a/yarns/lib.py +++ b/yarns/lib.py @@ -104,6 +104,9 @@ class EffiAPI: def GET(self, path, headers, body): self.request(requests.get, path, headers, body) + def DELETE(self, path, headers, body): + self.request(requests.delete, path, headers, body) + def request(self, func, path, headers, body): url = '{}{}'.format(self.v['baseurl'], path) self.v['request'] = { -- cgit v1.2.1