summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-01-30 13:50:02 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2014-01-30 13:50:02 +0000
commit5e0b76d22be2d114bcd3d853ee79c74f25fad806 (patch)
treeed0300e0c604338cd92d1a0d75762848cfb34f4b
parent85330689c2ddacdbc477607254849345a53d6ea6 (diff)
downloadlorry-controller-5e0b76d22be2d114bcd3d853ee79c74f25fad806.tar.gz
Use JSON values instead of Python values
In the "THEN response has ... set to ..." step, we now require JSON values instead of Python ones. This allows us to avoid having to use eval() in Python. Suggested-by: Richard Maw
-rw-r--r--yarns.webapp/020-status.yarn2
-rw-r--r--yarns.webapp/030-queue-management.yarn8
-rw-r--r--yarns.webapp/900-implementations.yarn6
3 files changed, 8 insertions, 8 deletions
diff --git a/yarns.webapp/020-status.yarn b/yarns.webapp/020-status.yarn
index ba8c903..cf0c634 100644
--- a/yarns.webapp/020-status.yarn
+++ b/yarns.webapp/020-status.yarn
@@ -9,6 +9,6 @@ it has no Lorry or Trove specs.
GIVEN a running WEBAPP
WHEN admin makes request GET /1.0/status
THEN response is JSON
- AND response has running-queue set to False
+ AND response has running-queue set to false
FINALLY WEBAPP terminates
diff --git a/yarns.webapp/030-queue-management.yarn b/yarns.webapp/030-queue-management.yarn
index 75b17e3..b58a63f 100644
--- a/yarns.webapp/030-queue-management.yarn
+++ b/yarns.webapp/030-queue-management.yarn
@@ -13,22 +13,22 @@ new jobs, and later to start it again.
SCENARIO admin can start and stop WEBAPP job scheduling
GIVEN a running WEBAPP
WHEN admin makes request GET /1.0/status
- THEN response has running-queue set to False
+ THEN response has running-queue set to false
WHEN admin makes request GET /1.0/start-queue
AND admin makes request GET /1.0/status
- THEN response has running-queue set to True
+ THEN response has running-queue set to true
Further, the state change needs to be persistent across WEBAPP
instances, so we kill the WEBAPP that's currently running, and start a
-new one, and verify that the `running-queue` status is still `True`.
+new one, and verify that the `running-queue` status is still `true`.
WHEN WEBAPP is terminated
THEN WEBAPP isn't running
GIVEN a running WEBAPP
WHEN admin makes request GET /1.0/status
- THEN response has running-queue set to True
+ THEN response has running-queue set to true
Finally, clean up.
diff --git a/yarns.webapp/900-implementations.yarn b/yarns.webapp/900-implementations.yarn
index 7bfb6bb..6886adc 100644
--- a/yarns.webapp/900-implementations.yarn
+++ b/yarns.webapp/900-implementations.yarn
@@ -100,15 +100,15 @@ Check the Content-Type of the response is JSON.
A JSON response can then be queried further. The JSON is expected to
be a dict, so that values are accessed by name from the dict. The
-value is expresssed as a Python value in the step.
+value is expresssed as a JSON value in the step.
- IMPLEMENTS THEN response has (\S+) set to (\S+)
+ IMPLEMENTS THEN response has (\S+) set to (.+)
cat "$DATADIR/response.body"
python -c "
import json, os, sys
data = json.load(sys.stdin)
key = os.environ['MATCH_1']
- expected = eval(os.environ['MATCH_2']) # I feel dirty and evil.
+ expected = json.loads(os.environ['MATCH_2'])
value = data[key]
if value != expected:
sys.stderr.write(