Changeset - a451a3cf2b41
roles/common/molecule/default/files/pip_check_requirements_upgrades-py3/with_updates/requirements.in
Show inline comments
 
new file 100644
 
urllib3~=1.24.0
roles/common/molecule/default/files/pip_check_requirements_upgrades-py3/with_updates/requirements.txt
Show inline comments
 
new file 100644
 
#
 
# This file is autogenerated by pip-compile
 
# To update, run:
 
#
 
#    pip-compile
 
#
 
urllib3==1.24.2           # via -r requirements.in
roles/common/molecule/default/files/pip_check_requirements_upgrades-py3/without_updates/requirements.in
Show inline comments
 
new file 100644
 
urllib3~=1.24.0
roles/common/molecule/default/files/pip_check_requirements_upgrades-py3/without_updates/requirements.txt
Show inline comments
 
new file 100644
 
#
 
# This file is autogenerated by pip-compile
 
# To update, run:
 
#
 
#    pip-compile
 
#
 
urllib3==1.24.3           # via -r requirements.in
roles/common/molecule/default/files/pip_check_requirements_upgrades/with_updates/requirements.in
Show inline comments
 
new file 100644
 
urllib3~=1.24.0
roles/common/molecule/default/files/pip_check_requirements_upgrades/with_updates/requirements.txt
Show inline comments
 
new file 100644
 
#
 
# This file is autogenerated by pip-compile
 
# To update, run:
 
#
 
#    pip-compile
 
#
 
urllib3==1.24.2           # via -r requirements.in
roles/common/molecule/default/files/pip_check_requirements_upgrades/without_updates/requirements.in
Show inline comments
 
new file 100644
 
urllib3~=1.24.0
roles/common/molecule/default/files/pip_check_requirements_upgrades/without_updates/requirements.txt
Show inline comments
 
new file 100644
 
#
 
# This file is autogenerated by pip-compile
 
# To update, run:
 
#
 
#    pip-compile
 
#
 
urllib3==1.24.3           # via -r requirements.in
roles/common/molecule/default/playbook.yml
Show inline comments
 
@@ -13,3 +13,40 @@
 
  become: true
 
  roles:
 
    - common
 

	
 
- hosts: parameters-mandatory,parameters-optional
 
  become: true
 
  tasks:
 

	
 
    - name: Set-up directories for testing pip requirements upgrade checks script
 
      file:
 
        path: "{{ item }}"
 
        state: directory
 
        owner: root
 
        group: pipreqcheck
 
        mode: 0750
 
      with_items:
 
        - "/tmp/pip_check_requirements_upgrades"
 
        - "/tmp/pip_check_requirements_upgrades/with_updates"
 
        - "/tmp/pip_check_requirements_upgrades/without_updates"
 
        - "/tmp/pip_check_requirements_upgrades-py3"
 
        - "/tmp/pip_check_requirements_upgrades-py3/with_updates"
 
        - "/tmp/pip_check_requirements_upgrades-py3/without_updates"
 

	
 
    - name: Deploy files for testing pip requirements upgrade checks script
 
      copy:
 
        src: "{{ item }}"
 
        dest: "/tmp/{{ item }}"
 
        owner: root
 
        group: pipreqcheck
 
        mode: 0640
 
        directory_mode: 0750
 
      with_items:
 
        - "pip_check_requirements_upgrades/with_updates/requirements.in"
 
        - "pip_check_requirements_upgrades/with_updates/requirements.txt"
 
        - "pip_check_requirements_upgrades/without_updates/requirements.in"
 
        - "pip_check_requirements_upgrades/without_updates/requirements.txt"
 
        - "pip_check_requirements_upgrades-py3/with_updates/requirements.in"
 
        - "pip_check_requirements_upgrades-py3/with_updates/requirements.txt"
 
        - "pip_check_requirements_upgrades-py3/without_updates/requirements.in"
 
        - "pip_check_requirements_upgrades-py3/without_updates/requirements.txt"
roles/common/molecule/default/tests/test_default.py
Show inline comments
 
import os
 
import re
 

	
 
import testinfra.utils.ansible_runner
 

	
 
@@ -403,3 +404,30 @@ def test_pipreqcheck_virtualenv_wrong_python_version_not_present(host, wrong_pyt
 
        wrong_python_path_file = host.file(wrong_python_path)
 

	
 
        assert not wrong_python_path_file.exists
 

	
 

	
 
@pytest.mark.parametrize('environment,config_directory', [
 
    ('/var/lib/pipreqcheck/virtualenv', '/tmp/pip_check_requirements_upgrades'),
 
    ('/var/lib/pipreqcheck/virtualenv-py3', '/tmp/pip_check_requirements_upgrades-py3'),
 
])
 
def test_pipreqcheck_script_output(host, environment, config_directory):
 
    """
 
    Tests if the pip_check_requirements_upgrades.sh script properly
 
    reports available updates or not.
 
    """
 

	
 
    expected_line_count = 9
 
    expected_warning_message = "[WARN]  Upgrades available for: %s/with_updates/requirements.txt" % config_directory
 
    expected_package_diff = "@@ -1 +1 @@\n-urllib3==1.24.2\n+urllib3==1.24.3"
 

	
 
    with host.sudo("pipreqcheck"):
 
        report = host.run("/usr/local/bin/pip_check_requirements_upgrades.sh -q -V %s %s", environment, config_directory)
 

	
 
        # Clean-up the SSH warning from the beginning of stderr if
 
        # present.
 
        stderr = re.sub("^Warning: Permanently added.*?\r\n", "", report.stderr)
 

	
 
    assert stderr == ""
 
    assert len(report.stdout.split("\n")) == expected_line_count
 
    assert expected_warning_message in report.stdout
 
    assert expected_package_diff in report.stdout
0 comments (0 inline, 0 general)