Skip to content

Commit

Permalink
lce/cv
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Nov 5, 2024
1 parent 982dfc5 commit 9bcf70d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,16 @@ def container_repository(product, organization, foremanapi):
repo = foremanapi.create('repositories', {'name': str(uuid.uuid4()), 'product_id': product['id'], 'content_type': 'docker', 'url': 'https://quay.io/', 'docker_upstream_name': 'foreman/busybox-test'})
yield repo
foremanapi.delete('repositories', repo)

@pytest.fixture
def lifecycle_environment(organization, foremanapi):
library = foremanapi.list('lifecycle_environments', 'name=Library', {'organization_id': organization['id']})[0]
lce = foremanapi.create('lifecycle_environments', {'name': str(uuid.uuid4()), 'organization_id': organization['id'], 'prior_id': library['id']})
yield lce
foremanapi.delete('lifecycle_environments', lce)

@pytest.fixture
def content_view(organization, foremanapi):
cv = foremanapi.create('content_views', {'name': str(uuid.uuid4()), 'organization_id': organization['id']})
yield cv
foremanapi.delete('content_views', cv)
17 changes: 17 additions & 0 deletions tests/foreman_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ def test_foreman_file_repository(file_repository, foremanapi, ssh_config):
def test_foreman_container_repository(container_repository, foremanapi, ssh_config):
assert container_repository
foremanapi.resource_action('repositories', 'sync', {'id': container_repository['id']})


def test_foreman_lifecycle_environment(lifecycle_environment):
assert lifecycle_environment


def test_foreman_content_view(content_view, yum_repository, foremanapi):
assert content_view
foremanapi.update('content_views', {'id': content_view['id'], 'repository_ids': [yum_repository['id']]})
foremanapi.resource_action('content_views', 'publish', {'id': content_view['id']})
# do something with the published view
versions = foremanapi.list('content_view_versions', params={'content_view_id': content_view['id']})
for version in versions:
current_environment_ids = {environment['id'] for environment in version['environments']}
for environment_id in current_environment_ids:
foremanapi.resource_action('content_views', 'remove_from_environment', params={'id': content_view['id'], 'environment_id': environment_id})
foremanapi.delete('content_view_versions', version)

0 comments on commit 9bcf70d

Please sign in to comment.