This repository contains a set of .json files that specify conditions for unit tests on the OT API. The specifications are intended to be used across languages, at present wrappers in R, Python, and Ruby are using them. Further discussion is available on the open tree wiki
See the individual language implementations for example usage.
If you want curl the raw files directly you can use the raw.gihubusercontent.com reference to an individual files like so:
https://raw.githubusercontent.com/OpenTreeOfLife/shared-api-tests/master/graph_of_life.json
There is one file for each API: taxonomy, trns, graph_of_life, studies, and tree_of_life. Within each file there are multiple named "tests". The basic format for an individual "test" (or testing context) is:
{
"test_name": {
"test_function": "test_function_name",
"test_input": { dictionary_of_input },
"tests": { dictionary_of_tests }
}
}
A descriptive name wrapping a set of tests.
The name of a binding function. Function names were designed to be shared across R, Python, and Ruby. They map 1:1 with an API URL. The naming convention is referenced on the open tree wiki.
A dictionary of tests organized by type. Most of the individual tests are in the format:
[specification, message]
The message is the message to display when the tests fails.
Some types of tests allow for multiple tests to be defined.
The following types of tests are available:
- contains - Tests that a key is present in the response.
- contains_error - Tests that the response contains the a key "error".
- deep_equals - Tests that a nested key in the response return a specific value.
- equals - Tests that one or more keys in the response return a specific value.
- length_greater_than - Tests that the value for a given key contains greater than N items.
- of_type - Tests that the response provided is of the specified type.
- parameters_error - Tests that the request object has detected, prior to askign for a response, that the parameters passed are invalid.
Value is a string.
"message'
Value is an Array of Arrays. Each inner Array defines a response key to check for and message to provide on failure of the test.
[
["key","message"],
["other_key", "other_message']
]
Value is an Array of Arrays. Each inner Array contains an array with a key/value pair, and a message.
[
[ ["key", "value'], "message" ],
[ ["other_key", "other_value'], "message"]
]
Value is an Array of Arrays. Each inner Array contains:
{
[
[
[ ["key1","key2", "key3"], "value'], "message" ]
],
[
...
]
]
This is is translated to the test:
response[key1][key2][key3] == value
Points to message.
"message"
Where ErrorName is the class in {what language} that is raised.
Value is an Array of Arrays, each inner Array looks like
[
["response_key",bound_value], "message"
]
Value is an Array with two values:
[type, message]
At present only 'dict' is used as a type. This corresponds to a Ruby Hash.
Fork the repo, add the test, VALIDATE THE JSON, and send us a pull request.
BSD