|
| 1 | +import os |
| 2 | +import re |
| 3 | +import requests |
| 4 | +import pytest |
| 5 | +import json |
| 6 | + |
| 7 | +PLM_VER = os.environ.get("PLM_VERSION") |
| 8 | +SOFTWARE_FILES = ['bookworm','bullseye','redhat/9','redhat/8','jammy','noble','redhat/2023', 'source'] |
| 9 | + |
| 10 | +def get_package_tuples(): |
| 11 | + list = [] |
| 12 | + for software_files in SOFTWARE_FILES: |
| 13 | + data = 'version_files=percona-link-mongodb-' + PLM_VER + '|percona-link-mongodb&software_files=' + software_files |
| 14 | + req = requests.post("https://www.percona.com/products-api.php",data=data,headers = {"content-type": "application/x-www-form-urlencoded; charset=UTF-8"}) |
| 15 | + assert req.status_code == 200 |
| 16 | + assert req.text != '[]', software_files |
| 17 | + if software_files == 'binary': |
| 18 | + assert "percona-link-mongodb-" + PLM_VER in req.text |
| 19 | + else: |
| 20 | + assert "percona-link-mongodb-" + PLM_VER in req.text or "percona-link-mongodb_" + PLM_VER in req.text |
| 21 | + files = json.loads(req.text) |
| 22 | + for file in files: |
| 23 | + list.append( (software_files,file['filename'],file['link']) ) |
| 24 | + print(list) |
| 25 | + return list |
| 26 | + |
| 27 | +LIST_OF_PACKAGES = get_package_tuples() |
| 28 | + |
| 29 | +@pytest.mark.parametrize(('software_files','filename','link'),LIST_OF_PACKAGES) |
| 30 | +def test_packages_site(software_files,filename,link): |
| 31 | + print('\nTesting ' + software_files + ', file: ' + filename) |
| 32 | + print(link) |
| 33 | + req = requests.head(link) |
| 34 | + if not re.search(r'percona-link-mongodb.*\.diff\.gz', link): |
| 35 | + assert req.status_code == 200 and int(req.headers['content-length']) > 0, link |
0 commit comments