Files
@ 0bfda9b0c3fe
Branch filter:
Location: majic-ansible-roles/roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py - annotation
0bfda9b0c3fe
3.0 KiB
text/x-python
MAR-132: Pin packages as part of wsgi_website role test to ensure reproducability:
- Provide explicit list of packages being deployed. This should ensure
we can always reproduce the tests without being affected by new
releases of packages.
- Updated expected requirements in test for the jedi version.
- Provide explicit list of packages being deployed. This should ensure
we can always reproduce the tests without being affected by new
releases of packages.
- Updated expected requirements in test for the jedi version.
b5ed796b566a 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 b5ed796b566a 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 c8d4251a6ea5 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['all'])
def test_wsgi_requirements_upgrade_checks(host):
"""
Tests if Python requirements files for upgrade checks are set-up correctly.
"""
with host.sudo():
directory = host.file('/etc/pip_check_requirements_upgrades/parameters-paste-req')
assert directory.is_directory
assert directory.user == 'root'
assert directory.group == 'pipreqcheck'
assert directory.mode == 0o750
config = host.file('/etc/pip_check_requirements_upgrades/parameters-paste-req/wsgi_requirements.in')
assert config.is_file
assert config.user == 'root'
assert config.group == 'pipreqcheck'
assert config.mode == 0o640
assert config.content == "gunicorn\nfutures"
config = host.file('/etc/pip_check_requirements_upgrades/parameters-paste-req/wsgi_requirements.txt')
assert config.is_file
assert config.user == 'root'
assert config.group == 'pipreqcheck'
assert config.mode == 0o640
assert config.content == "futures==3.1.0\ngunicorn==19.7.0"
def test_gunicorn_requirements_installation_file(host):
"""
Tests if requirements file for installing Gunicorn has been deployed
correctly.
"""
with host.sudo():
requirements = host.file('/var/www/parameters-paste-req/.wsgi_requirements.txt')
assert requirements.is_file
assert requirements.user == 'admin-parameters-paste-req'
assert requirements.group == 'web-parameters-paste-req'
assert requirements.mode == 0o640
assert requirements.content == "futures==3.1.0\ngunicorn==19.7.0"
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-paste-req/')
assert page.rc == 0
assert "This is the WSGI application at parameters-paste-req." in page.stdout
assert "Requested URL was: https://parameters-paste-req/" 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-paste-req/static/static_file.txt')
assert page.rc == 0
assert "This is the WSGI application at parameters-paste-req." in page.stdout
assert "Requested URL was: https://parameters-paste-req/static/static_file.txt" in page.stdout
page = host.run('curl https://parameters-paste-req/media/media_file.txt')
assert page.rc == 0
assert "This is the WSGI application at parameters-paste-req." in page.stdout
assert "Requested URL was: https://parameters-paste-req/media/media_file.txt" in page.stdout
|