summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-03-10 14:40:14 +0200
committerLars Wirzenius <liw@liw.fi>2019-03-10 14:40:14 +0200
commit654f088bab35aff16cd999a5744b8f045e2cc49b (patch)
treeda4023bd46d247b816d72666cf72da2e76329a05 /yarns
parent3a37ad5eff9af642424c519159d74ce9abe7a926 (diff)
downloadeffi-reg-654f088bab35aff16cd999a5744b8f045e2cc49b.tar.gz
Add: Delete members
Diffstat (limited to 'yarns')
-rw-r--r--yarns/000.yarn37
-rw-r--r--yarns/lib.py3
2 files changed, 32 insertions, 8 deletions
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'] = {