Tried both with no luck:
- I cannot use
And context is cleaned up
because I need the id from the created record to delete it in the second scenario.
- I tried the
Given format "RAW"
but it still fails.
This is the test right now:
Feature: Login creation and deletion
Scenario: REST login creation with required fields only
Given address "@address"
Given URL path "/genesisng/logins/create"
Given HTTP method "POST"
Given format "JSON"
Given request "login-create-lskywalker.json"
When the URL is invoked
Then JSON Pointer "/response/id" isn't empty
And JSON Pointer "/response/username" is "lskywalker"
And JSON Pointer "/response/name" is "Luke"
And JSON Pointer "/response/email" is "lskywalker@gmail.com"
And JSON Pointer "/response/is_admin" is false
And status is "201"
And header "Location" isn't empty
And I store "/response/id" from response under "id"
Scenario: REST login deletion of previously created login
Given address "@address"
Given URL path "/genesisng/logins/#{id}/delete"
Given HTTP method "GET"
Given format "RAW"
When the URL is invoked
Then status is "204"
This is the output of the test:
$ apitest run ~/Projects/genesisng/apitest/
Feature: Login creation and deletion
Scenario: REST login creation with required fields only
Given address "@address"
Given URL path "/genesisng/logins/create"
Given HTTP method "POST"
Given format "JSON"
Given request "login-create-lskywalker.json"
When the URL is invoked
Then JSON Pointer "/response/id" isn't empty
And JSON Pointer "/response/username" is "lskywalker"
And JSON Pointer "/response/name" is "Luke"
And JSON Pointer "/response/email" is "lskywalker@gmail.com"
And JSON Pointer "/response/is_admin" is false
And status is "201"
And header "Location" isn't empty
And I store "/response/id" from response under "id"
Scenario: REST login deletion of previously created login
Given address "@address"
Given URL path "/genesisng/logins/#{id}/delete"
Given HTTP method "GET"
Given format "RAW"
When the URL is invoked
Then status is "204"
Assertion Failed: Status expected `204`, received `500`
And this is the trace I found on the logs:
2018-11-05 15:37:40,176 DEBG 'zato-server1' stdout output:
2018-11-05 15:37:40,176 - WARNING - 137:DummyThread-122 - zato.common.util:488 - Could not parse request as JSON:`username=lskywalker&password=123456&name=Luke&email=lskywalker%40gmail.com`, e:`Traceback (most recent call last):
File "/opt/zato/3.0/code/zato-common/src/zato/common/util/__init__.py", line 486, in payload_from_request
payload = loads(request)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/anyjson/__init__.py", line 135, in loads
return implementation.loads(value, *args, **kwargs)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/anyjson/__init__.py", line 99, in loads
return self._decode(s, *args, **kwargs)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/simplejson/__init__.py", line 488, in loads
return _default_decoder.decode(s)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
ValueError: Expecting value: line 1 column 1 (char 0)
`
2018-11-05 15:37:40,177 DEBG 'zato-server1' stdout output:
2018-11-05 15:37:40,176 - ERROR - 137:DummyThread-122 - zato.server.connection.http_soap.channel:324 - Caught an exception, cid:`8c824acf60e4c72ed17eaf45`, status_code:`500`, _format_exc:`Traceback (most recent call last):
File "/opt/zato/3.0/code/zato-server/src/zato/server/connection/http_soap/channel.py", line 268, in dispatch
payload, worker_store, self.simple_io_config, post_data, path_info, soap_action)
File "/opt/zato/3.0/code/zato-server/src/zato/server/connection/http_soap/channel.py", line 502, in handle
params_priority=channel_item.params_pri)
File "/opt/zato/3.0/code/zato-server/src/zato/server/service/__init__.py", line 431, in update_handle
payload = payload_from_request(cid, raw_request, data_format, transport)
File "/opt/zato/3.0/code/zato-common/src/zato/common/util/__init__.py", line 486, in payload_from_request
payload = loads(request)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/anyjson/__init__.py", line 135, in loads
return implementation.loads(value, *args, **kwargs)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/anyjson/__init__.py", line 99, in loads
return self._decode(s, *args, **kwargs)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/simplejson/__init__.py", line 488, in loads
return _default_decoder.decode(s)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/opt/zato/3.0/code/local/lib/python2.7/site-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
ValueError: Expecting value: line 1 column 1 (char 0)
Maybe my approach is not an expected one? How would you have me test the Delete service? Load the test data, then execute tests, which will try to delete a known id? Then, if I have to test again, do it after droping and creating the schema, and loading the test data again? (so that the scenario is exactly as before)