Skip to content

Commit

Permalink
yum/file
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Nov 4, 2024
1 parent c93f0d1 commit 2a77e2e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ def product(organization, foremanapi):
foremanapi.delete('products', prod)

@pytest.fixture
def repository(product, organization, foremanapi):
repo = foremanapi.create('repositories', {'name': str(uuid.uuid4()), 'product_id': product['id'], 'content_type': 'yum'})
def yum_repository(product, organization, foremanapi):
repo = foremanapi.create('repositories', {'name': str(uuid.uuid4()), 'product_id': product['id'], 'content_type': 'yum', 'url': 'https://fixtures.pulpproject.org/rpm-no-comps/'})
yield repo
foremanapi.delete('repositories', repo)

@pytest.fixture
def file_repository(product, organization, foremanapi):
repo = foremanapi.create('repositories', {'name': str(uuid.uuid4()), 'product_id': product['id'], 'content_type': 'file', 'url': 'https://fixtures.pulpproject.org/file/'})
yield repo
foremanapi.delete('repositories', repo)
24 changes: 22 additions & 2 deletions tests/foreman_api_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import urllib.parse

import requests


def _repo_url(repo, ssh_config):
return urllib.parse.urlunparse(urllib.parse.urlparse(repo['full_path'])._replace(netloc=ssh_config['hostname']))


def test_foreman_organization(organization):
assert organization

def test_foreman_product(product):
assert product

def test_foreman_repository(repository):
assert repository
def test_foreman_yum_repository(yum_repository, foremanapi, ssh_config):
assert yum_repository
foremanapi.resource_action('repositories', 'sync', {'id': yum_repository['id']})
repo_url = _repo_url(yum_repository, ssh_config)
assert requests.get(f'{repo_url}/repodata/repomd.xml', verify=False)
assert requests.get(f'{repo_url}/Packages/b/bear-4.1-1.noarch.rpm', verify=False)


def test_foreman_file_repository(file_repository, foremanapi, ssh_config):
assert file_repository
foremanapi.resource_action('repositories', 'sync', {'id': file_repository['id']})
repo_url = _repo_url(file_repository, ssh_config)
assert requests.get(f'{repo_url}/1.iso', verify=False)

0 comments on commit 2a77e2e

Please sign in to comment.