|
1 | | -import urllib.parse |
2 | | - |
3 | | -import requests |
4 | | - |
5 | | - |
6 | | -def _repo_url(repo, ssh_config): |
7 | | - return urllib.parse.urlunparse(urllib.parse.urlparse(repo['full_path'])._replace(netloc=ssh_config['hostname'])) |
8 | | - |
9 | | - |
10 | 1 | def test_foreman_organization(organization): |
11 | 2 | assert organization |
12 | | - |
13 | | -def test_foreman_product(product): |
14 | | - assert product |
15 | | - |
16 | | -def test_foreman_yum_repository(yum_repository, foremanapi, ssh_config): |
17 | | - assert yum_repository |
18 | | - foremanapi.resource_action('repositories', 'sync', {'id': yum_repository['id']}) |
19 | | - repo_url = _repo_url(yum_repository, ssh_config) |
20 | | - assert requests.get(f'{repo_url}/repodata/repomd.xml', verify=False) |
21 | | - assert requests.get(f'{repo_url}/Packages/b/bear-4.1-1.noarch.rpm', verify=False) |
22 | | - |
23 | | - |
24 | | -def test_foreman_file_repository(file_repository, foremanapi, ssh_config): |
25 | | - assert file_repository |
26 | | - foremanapi.resource_action('repositories', 'sync', {'id': file_repository['id']}) |
27 | | - repo_url = _repo_url(file_repository, ssh_config) |
28 | | - assert requests.get(f'{repo_url}/1.iso', verify=False) |
29 | | - |
30 | | - |
31 | | -def test_foreman_container_repository(container_repository, foremanapi, ssh_config): |
32 | | - assert container_repository |
33 | | - foremanapi.resource_action('repositories', 'sync', {'id': container_repository['id']}) |
34 | | - |
35 | | - |
36 | | -def test_foreman_lifecycle_environment(lifecycle_environment): |
37 | | - assert lifecycle_environment |
38 | | - |
39 | | - |
40 | | -def test_foreman_content_view(content_view, yum_repository, foremanapi): |
41 | | - assert content_view |
42 | | - foremanapi.update('content_views', {'id': content_view['id'], 'repository_ids': [yum_repository['id']]}) |
43 | | - foremanapi.resource_action('content_views', 'publish', {'id': content_view['id']}) |
44 | | - # do something with the published view |
45 | | - versions = foremanapi.list('content_view_versions', params={'content_view_id': content_view['id']}) |
46 | | - for version in versions: |
47 | | - current_environment_ids = {environment['id'] for environment in version['environments']} |
48 | | - for environment_id in current_environment_ids: |
49 | | - foremanapi.resource_action('content_views', 'remove_from_environment', params={'id': content_view['id'], 'environment_id': environment_id}) |
50 | | - foremanapi.delete('content_view_versions', version) |
51 | | - |
52 | | - |
53 | | -def test_foreman_manifest(organization, foremanapi, fixture_dir): |
54 | | - manifest_path = fixture_dir / 'manifest.zip' |
55 | | - with open(manifest_path, 'rb') as manifest_file: |
56 | | - files = {'content': (str(manifest_path), manifest_file, 'application/zip')} |
57 | | - params = {'organization_id': organization['id']} |
58 | | - foremanapi.resource_action('subscriptions', 'upload', params, files=files) |
0 commit comments