Skip to main content

Schul-Cloud Content API

Project description

Build Status Python Package Index

This repository contains

  • a server to test scrapers against

  • tests to test the server

Installation

Using pip, you can install all dependencies like this:

pip install schul_cloud_ressources_server_tests

When you are done, you can import the package.

import schul_cloud_ressources_server_tests

Usage

This section describes how to use the server and the tests.

Server

You can find the API definition. The server serves according to the API. It verifies the input and output for correctness.

To start the server, run

python3 -m schul_cloud_ressources_server_tests.app

The server should appear at http://localhost:8080/v1.

Tests

You always test against the running server. Tests may delete everyting you can reach. If you test the running server, make sure to authenticate in a way that does not destroy the data you want to keep.

python -m schul_cloud_ressources_server_tests.tests --url=http://localhost:8080/v1/

http://localhost:8080/v1/ is the default url.

Steps for Implementation

If you want to implement your server you can follow the TDD steps to implement one test after the other.

python -m schul_cloud_ressources_server_tests.tests -m step1
python -m schul_cloud_ressources_server_tests.tests -m step2
python -m schul_cloud_ressources_server_tests.tests -m step3
...
  • step1 runs the first test

  • step2 runs the first and the second test

  • step3 runs the first, second and third test

You can run a single test with

python -m schul_cloud_ressources_server_tests.tests -m step3only

Test Authentication

The test server supports api key authentication and basic authentication. If you test authentication over the internet, using https protects the secrets. Thus, an example test call to your api could look like this:

python -m schul_cloud_ressources_server_tests.tests  \
       --url=http://url.to/your/server               \
       --noauth=false --basic=username:password

If you have an api key, you can test that the server works. Do not forget the : before the api key.

python -m schul_cloud_ressources_server_tests.tests   \
       --url=http://url.to/your/server                \
       --noauth=false --apikey=:apikey

By default the test server accepts authentication with several credentials

  • no authentication

  • basic:

    • user valid1@schul-cloud.org password 123abc

    • user valid2@schul-cloud.org password supersecure

  • api key: abcdefghijklmn for the user valid1@schul-cloud.org. The client does not send the user name to the server.

To test these, you can add the --basic and --apikey parameters several times to the tests. The --noauth=true parameter is default. If the api only accepts authenticated requests, set --noauth=false.

python -m schul_cloud_ressources_server_tests.tests    \
       --basic=valid1@schul-cloud.org:123abc           \
       --basic=valid2@schul-cloud.org:supersecure      \
       --apikey=valid1@schul-cloud.org:abcdefghijklmn  \
       --noauth=true

All tests are run with the different authentication options. If we have several ways to authenticate, test if the user sees the other posts.

It is assumed, that adding invalid to the password, user name and api key will make it invalid. Tests use the invalid credentials to test the server behavior in rejected cases.

Example Travis Configuration

If you want to implement a crawler or server, you can use Travis-CI to test it. An example travis configuration can be found in the test-example branch. You can view the output The configuration is generic. It will run under any other language you configure.

TODO

  • generate a docker container for the server

  • generate a docker container for the tests

  • document how to embed the tests and the server in

    • a crawler

    • travis build script of arbitrary language

  • create example crawler with tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

schul_cloud_ressources_server_tests-1.0.22.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file schul_cloud_ressources_server_tests-1.0.22.tar.gz.

File metadata

File hashes

Hashes for schul_cloud_ressources_server_tests-1.0.22.tar.gz
Algorithm Hash digest
SHA256 909a66d80f831ad0cdc501648aa0f04a63ad937729e9aac23336b3b81756881e
MD5 6aced9244a8848fdfa1e85dd17b531a3
BLAKE2b-256 5dfb49f861a1b1eaf1fc88698378defa1ae75b5e5514ace6477dac421f591367

See more details on using hashes here.

File details

Details for the file schul_cloud_ressources_server_tests-1.0.22-py3-none-any.whl.

File metadata

File hashes

Hashes for schul_cloud_ressources_server_tests-1.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 e565574f307db51def628f5e336516688432998fe57741197f7151099ceb9051
MD5 ede3147847686eeb6b776b7b045da66d
BLAKE2b-256 fee64fc51915674e6ee3896289a09893d81bf9e791674aae29fb202d889eefc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page