Skip to main content

Schul-Cloud Ressources Server Tests

Build Status Python Package Index

This repository contains

  • a server to test scrapers against

  • tests to test the server

The package works under Python 2 and 3.

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

python -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. Use https to protect the secrets. Thus, an example test call to your api could look like this:

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

If you have an api key, you can test that the server works.

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, the tests test if the user sees the other users’ data.

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.

Use the server in pytest

You can use the sever in Python tests. There are fixtures available that start and stop the server.

from schul_cloud_ressources_server_tests.tests.fixtures import *

def test_pytest(ressources_server):
    """pytest using the server"""

The following attributes are available:

  • ressources_server.url The url of the server.

  • ressources_server.api A schul_cloud_ressources_api_v1.RessourcesApi object connected to the server.

  • ressources_server.get_ressources() A function to return a list of ressources on the server.

For more information, see the module schul_cloud_ressources_server_tests.tests.fixtures. You can add support for more test frameworks.

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

Metadata

Release files for schul-cloud-ressources-server-tests 1.0.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schul-cloud-ressources-server-tests 1.0.27
File Size Uploaded Provenance
schul_cloud_ressources_server_tests-1.0.27.tar.gz 13.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for schul-cloud-ressources-server-tests 1.0.27
File Interpreter ABI Platform
schul_cloud_ressources_server_tests-1.0.27-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / schul_cloud_ressources_server_tests-1.0.27.tar.gz

Download URL schul_cloud_ressources_server_tests-1.0.27.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8e14920c803b2f081c35ad8be9d4a243b0dd2f24e9d3bd606f1341238ae76ff2
BLAKE2b-256 checksum
How to use checksums
3063c282e2732125f0937f19aba9dec547b2385d356a3d2b8db230fa18fb3150
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / schul_cloud_ressources_server_tests-1.0.27-py3-none-any.whl

Download URL schul_cloud_ressources_server_tests-1.0.27-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a8cd8c1d8f4575b3b19935c8e121bfc8cc269c9590372e072c6da7221cef5b5
BLAKE2b-256 checksum
How to use checksums
7e0b03b2cd106e14ac30bd3ffcaf791457635c93936838ae0174b8e273691c6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for schul-cloud-ressources-server-tests 1.0.27

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page