Code Monkey home page Code Monkey logo

beacon-api-tests's Introduction

Validation tests for Beacon API

This project contains tests that can be used for any Beacon implemention using api version 1.0.1 and 1.1.0. The Beacon's responses are validated against the GA4GH's OpenAPI specification and against JSON schemas by CSCfi. Apart from this, the values returned by the beacon are also checked.

The project uses openapi-core and jsonschemas.

Running the test suite

Requirements: python3 and pip3.

To run, install dependencies:

pip3 install -r requirements.txt

Then run tests from a test file:

python3 beacon_api_tester.py --host http://localhost:5050 --test tests/test-v101-variants.yaml

This assumes that you have a beacon running on the host specified. The beacon should contain the test data specified in the tests. By running

python3 beacon_api_tester.py --show_data_files tests/test-v101-variants.yaml

you can see the file names containing the data needed. See more about test data below.

Test data

Each test specifies which data is assumes, in the field beacondata.

Currently, all test data is found in testdata.csv (v101) and testdata_mate.csv (v110). The data is given in comma separated format.

Current tests:

  • v1.0.1:

    • The info (/) endpoint answer. Json validation and the datasets in the answer.

    • Queries that are not allowed. Check that these return code 400. See tests/v101/test_errors.py

    • The structure and answers of some specific queries. See tests/test-v101-variants.yaml.

    • Having multiple datasets.

  • v1.1.0:

    • Structural variants (breakends)

Create or inspect tests:

To create more tests, see adding_tests.md. This file also gives more information on how to interpret each given test file. Contributions (in the form of pull requests) are very welcome!

More options

Validation options

Default: validate against the OpenAPI spec, the JSON schemas and check that the results match (eg. that we get the correct counts).

Other options:

  • --no_openapi Don't validate against the OpenAPI specification

  • --no_json Don't validate against the JSON Schemas

  • --only_structure Don't validate the resulting counts, frequencies etc.

Output options

Default: show information, warnings and error messages.

Other options:

  • --only_warn Only print warnings and errors

Other

Default: Beacons are 0-based.

Other options:

  • --one_based Test a beacon that is 1-based

Using local validation schemas

The OpenAPI specification can be downloaded from the GA4GH's GitHub repo. To use a local version of it, specify it's path in config/config.py:

# Path to the OpenAPI spec
SPEC = 'beacon.yaml'

The JSON schemas can be downloaded from the CSCfi's GitHub repo.
To use local versions, put them in a directory and specify it's path in config/config.py:

# Directory containing JSON schemas
SCHEMAS = 'schemas'

beacon-api-tests's People

Contributors

kusalananda avatar malinahlberg avatar viklund avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

kylegao

beacon-api-tests's Issues

Running error after the new update

After the latest update, got the following errors.
When revert to the last version, the error goes away.

$ python beacon_api_tester.py --host sv 
INFO: Running api tests...
Traceback (most recent call last):
  File "beacon_api_tester.py", line 85, in <module>
    utils.setup.Settings().set_args(c_args)
  File "/Users/gaobo/Desktop/projects/Beacon_Test/beacon-api-tests/utils/setup.py", line 72, in set_args
    for pathname in c_args.test:
TypeError: 'NoneType' object is not iterable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.