Skip to content

Commit

Permalink
Add test case to trigger the reclaim_space task
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedmik committed Mar 13, 2024
1 parent 80c2bbc commit 354be8a
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
from datetime import datetime
import re
from time import sleep
from urllib.parse import urlparse

from nailgun import client
from nailgun.entity_mixins import call_entity_method_with_timeout
import pytest

from robottelo import constants
from robottelo.config import settings
from robottelo.config import get_credentials, settings
from robottelo.constants import (
CONTAINER_REGISTRY_HUB,
CONTAINER_UPSTREAM_NAME,
Expand Down Expand Up @@ -1595,3 +1596,56 @@ def test_positive_content_counts_blank_update(
assert (
counts is None or len(counts['content_view_versions']) == 0
), f"No content counts expected, but got:\n{counts['content_view_versions']}."

def test_positive_reclaim_space(
self,
target_sat,
module_capsule_configured,
):
"""Verify the reclaim_space endpoint spawns the Reclaim space task
and apidoc references the endpoint correctly.
:id: eb16ed53-0489-4bb9-a0da-8d857a1c7d06
:setup:
1. A registered external Capsule.
:steps:
1. Trigger the reclaim space task via API, check it succeeds.
2. Check the apidoc references the correct endpoint.
:expectedresults:
1. Reclaim_space endpoint spawns the Reclaim space task and it succeeds.
2. Apidoc references the correct endpoint.
:CaseImportance: Medium
:BZ: 2218179
:customerscenario: true
"""
# Trigger the reclaim space task via API, check it succeeds
task = module_capsule_configured.nailgun_capsule.content_reclaim_space()
assert task, 'No task was created for reclaim space.'
assert (
'Actions::Pulp3::CapsuleContent::ReclaimSpace' in task['label']
), 'Unexpected task triggered'
assert 'success' in task['result'], 'Reclaim task did not succeed'

# Check the apidoc references the correct endpoint
response = client.get(
f'{target_sat.url}/apidoc/v2/capsule_content/reclaim_space.en.html',
auth=get_credentials(),
verify=False,
)
assert (
response.status_code == 200
), f'{response.request.path} returned HTTP{response.status_code}'

ep_path = target_sat.api.Capsule(id=module_capsule_configured.nailgun_capsule.id).path(
which='content_reclaim_space'
)
ep_path = urlparse(ep_path).path
ep_path = ep_path.replace(str(module_capsule_configured.nailgun_capsule.id), ':id')

assert f'POST {ep_path}' in response.text, 'Reclaim_space endpoint path missing in apidoc'

0 comments on commit 354be8a

Please sign in to comment.