-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
964 additions
and
41 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
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,47 @@ | ||
JSON feed tests | ||
=============== | ||
|
||
The files in this directory exercise the JSON feed parser. | ||
|
||
|
||
``*.json`` | ||
---------- | ||
|
||
Files in this directory contain JSON objects. | ||
They will contain a ``__tests`` key with a list of expected conditions. | ||
Each condition will be evaluated after parsing the feed. | ||
|
||
For example: | ||
|
||
.. code-block:: json | ||
{ | ||
"__tests": [ | ||
"version == 'json11'" | ||
], | ||
"version": "https://jsonfeed.org/version/1.1" | ||
} | ||
Files in this directory are automatically found, parsed, and tested. | ||
|
||
When writing tests please consider the following: | ||
|
||
* Test incorrect value types that do not match the JSON feed requirements. | ||
For example, test null values where a string is required. | ||
|
||
* Test incorrect value types that are not hashable in Python. | ||
For example, test lists where a string is required. | ||
|
||
* Test incorrect value types that are also iterable in Python. | ||
For example, test a JSON object where a list is required. | ||
|
||
* Write ``eval()`` strings using Unicode escape sequences as needed. | ||
This forces the test and JSON feed content to agree. | ||
For example, | ||
|
||
.. code-block:: json | ||
{ | ||
"__tests": ["title == '\ud83d\ude0e'"], | ||
"title": "😎" | ||
} |
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,12 @@ | ||
{ | ||
"__description": "author.avatar: missing a `name` key", | ||
"__tests": [ | ||
"len(feed['author_detail'].keys()) == 1", | ||
"feed['author_detail']['image'] == 'https://domain.example/i.jpeg'", | ||
"len(feed['authors'][0].keys()) == 1", | ||
"feed['authors'][0]['image'] == 'https://domain.example/i.jpeg'" | ||
], | ||
"author": { | ||
"avatar": "https://domain.example/i.jpeg" | ||
} | ||
} |
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,11 @@ | ||
{ | ||
"__description": "author.avatar: whitespace must be stripped", | ||
"__tests": [ | ||
"feed['author_detail']['image'] == 'https://domain.example/i.jpeg'", | ||
"feed['authors'][0]['image'] == 'https://domain.example/i.jpeg'" | ||
], | ||
"author": { | ||
"name": "abc", | ||
"avatar": " https://domain.example/i.jpeg " | ||
} | ||
} |
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,14 @@ | ||
{ | ||
"__description": "author.avatar: valid value", | ||
"__tests": [ | ||
"len(feed['author_detail'].keys()) == 2", | ||
"feed['author_detail']['image'] == 'https://domain.example/i.jpeg'", | ||
"len(feed['authors']) == 1", | ||
"len(feed['authors'][0].keys()) == 2", | ||
"feed['authors'][0]['image'] == 'https://domain.example/i.jpeg'" | ||
], | ||
"author": { | ||
"name": "abc", | ||
"avatar": "https://domain.example/i.jpeg" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"__description": "author: ignored when the object is empty", | ||
"__tests": [ | ||
"'author' not in feed", | ||
"'author_detail' not in feed", | ||
"'authors' not in feed" | ||
], | ||
"author": {} | ||
} |
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,11 @@ | ||
{ | ||
"__description": "author.name: whitespace must be stripped", | ||
"__tests": [ | ||
"feed['author'] == 'abc'", | ||
"feed['author_detail']['name'] == 'abc'", | ||
"feed['authors'][0]['name'] == 'abc'" | ||
], | ||
"author": { | ||
"name": " abc " | ||
} | ||
} |
Oops, something went wrong.