-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from xsnippet/get-snippet
Implement the /snippets/<id> route
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
fixtures: | ||
- XSnippetApi | ||
|
||
tests: | ||
- name: create a new snippet | ||
POST: /v1/snippets | ||
request_headers: | ||
content-type: application/json | ||
data: | ||
title: Hello, World! | ||
syntax: python | ||
content: print('Hello, World!') | ||
status: 201 | ||
|
||
- name: retrieve snippet (unsupported accept) | ||
GET: $LOCATION | ||
request_headers: | ||
accept: text/html | ||
response_headers: | ||
content-type: application/json | ||
status: 406 | ||
skip: content negotiation is not implemented yet | ||
|
||
- name: retrieve snippet (not found) | ||
GET: /v1/snippets/foobar | ||
response_headers: | ||
content-type: application/json | ||
response_json_paths: | ||
$.message: Snippet with id `foobar` is not found | ||
$.`len`: 1 | ||
status: 404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
common: | ||
- &datetime_regex /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+\+\d{2}:\d{2}$/ | ||
- &slug_regex /^[a-zA-Z0-9]+$/ | ||
|
||
fixtures: | ||
- XSnippetApi | ||
|
||
tests: | ||
- name: create a new snippet | ||
POST: /v1/snippets | ||
request_headers: | ||
content-type: application/json | ||
data: | ||
title: Hello, World! | ||
syntax: python | ||
content: print('Hello, World!') | ||
tags: | ||
- spam | ||
- eggs | ||
status: 201 | ||
|
||
- name: retrieve previously created snippet via Location header | ||
GET: $LOCATION | ||
response_headers: | ||
content-type: application/json | ||
response_json_paths: | ||
$.id: *slug_regex | ||
$.title: Hello, World! | ||
$.syntax: python | ||
$.content: print('Hello, World!') | ||
$.created_at: *datetime_regex | ||
$.updated_at: *datetime_regex | ||
$.tags.`sorted`: | ||
- eggs | ||
- spam | ||
$.`len`: 7 | ||
status: 200 | ||
|
||
- name: retrieve previously created snippet by ID | ||
GET: /v1/snippets/$HISTORY['create a new snippet'].$RESPONSE['id'] | ||
response_headers: | ||
content-type: application/json | ||
response_json_paths: | ||
$.id: *slug_regex | ||
$.title: Hello, World! | ||
$.syntax: python | ||
$.content: print('Hello, World!') | ||
$.created_at: *datetime_regex | ||
$.updated_at: *datetime_regex | ||
$.tags.`sorted`: | ||
- eggs | ||
- spam | ||
$.`len`: 7 | ||
status: 200 |