Files @ 325b9d16a72b
Branch filter:

Location: majic-ansible-roles/roles/wsgi_website/molecule/default/tests/test_parameters_mandatory.py

branko
MAR-151: Added support for Debian 10 Buster to common role:

- Updated tests.
- Updated role reference documentation.
- Updated role metadata information.
- Refactored IP plan for the test machines for better separation
between different types of machines and versions.
- Parametrised tests for limited connectivity using the maintenance
mode.
- Don't use MariaDB compat package in tests - name differs between
Debian 9 and Debian 10, and relevant parameter is already getting
tested properly using the remaining packages.
import os

import testinfra.utils.ansible_runner


testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory')


def test_index_page(host):
    """
    Tests if index page is served correctly. This covers:

    - Basic WSGI application operation.
    - Handling of environment variables.
    - Handling of proxy headers.
    """

    page = host.run('curl -H "Accept-Encoding: plain" https://parameters-mandatory/')

    assert page.rc == 0
    assert "This is the WSGI application at parameters-mandatory." in page.stdout
    assert "Requested URL was: https://parameters-mandatory/" in page.stdout
    assert "MY_ENV_VAR: None" in page.stdout
    assert "Accept-Encoding: plain" in page.stdout
    assert "Python version: 2." in page.stdout


def test_static_file_serving(host):
    """
    Tests serving of static files.
    """

    page = host.run('curl https://parameters-mandatory/static/static_file.txt')
    assert page.rc == 0
    assert "This is the WSGI application at parameters-mandatory." in page.stdout
    assert "Requested URL was: https://parameters-mandatory/static/static_file.txt" in page.stdout

    page = host.run('curl https://parameters-mandatory/media/media_file.txt')
    assert page.rc == 0
    assert "This is the WSGI application at parameters-mandatory." in page.stdout
    assert "Requested URL was: https://parameters-mandatory/media/media_file.txt" in page.stdout