Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.3] host GET/PUT read content_source_id (BZ1488130) #5307

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
81 changes: 80 additions & 1 deletion tests/foreman/api/test_host.py
Expand Up @@ -24,7 +24,7 @@
from requests.exceptions import HTTPError
from six.moves import http_client

from robottelo.api.utils import publish_puppet_module
from robottelo.api.utils import promote, publish_puppet_module
from robottelo.config import settings
from robottelo.constants import CUSTOM_PUPPET_REPO, ENVIRONMENT
from robottelo.datafactory import (
Expand Down Expand Up @@ -1275,6 +1275,85 @@ def test_negative_update_os(self):
self.assertNotEqual(
host.read().operatingsystem.read().name, new_os.name)

@run_only_on('sat')
@tier3
def test_positive_read_content_source_id(self):
"""Read the host content_source_id attribute from the read request
response

:id: 0a7fd8d4-1ea8-4b21-8c46-10579644fd11

:expectedresults: content_source_id is present in GET host request
response

:BZ: 1339613, 1488130

:CaseLevel: System
"""
proxy = entities.SmartProxy().search(
query={'url': 'https://{0}:9090'.format(settings.server.hostname)}
)[0].read()
lce = entities.LifecycleEnvironment(organization=self.org).create()
content_view = entities.ContentView(organization=self.org).create()
content_view.publish()
content_view = content_view.read()
promote(content_view.version[0], environment_id=lce.id)
host = entities.Host(
organization=self.org,
location=self.loc,
content_facet_attributes={
'content_source_id': proxy.id,
'content_view_id': content_view.id,
'lifecycle_environment_id': lce.id,
}
).create()
content_facet_attributes = getattr(host, 'content_facet_attributes')
self.assertIsNotNone(content_facet_attributes)
content_source_id = content_facet_attributes.get('content_source_id')
self.assertIsNotNone(content_source_id)
self.assertEqual(content_source_id, proxy.id)

@run_only_on('sat')
@tier3
def test_positive_update_content_source_id(self):
"""Read the host content_source_id attribute from the update request
response

:id: d47214d2-a54c-4385-abfb-a0607ecb6ec7

:expectedresults: content_source_id is present in PUT host request
response

:BZ: 1339613, 1488130

:CaseLevel: System
"""
proxy = entities.SmartProxy().search(query={
'url': 'https://{0}:9090'.format(settings.server.hostname)})[0]
lce = entities.LifecycleEnvironment(organization=self.org).create()
content_view = entities.ContentView(organization=self.org).create()
content_view.publish()
content_view = content_view.read()
promote(content_view.version[0], environment_id=lce.id)
host = entities.Host(
organization=self.org,
location=self.loc,
content_facet_attributes={
'content_view_id': content_view.id,
'lifecycle_environment_id': lce.id,
}
).create()
host.content_facet_attributes['content_source_id'] = proxy.id
# we need to ensure that content_source_id is returned by PUT request,
# we will use entity update_json as entity update method will invoke
# read method after PUT request completion
response = host.update_json(['content_facet_attributes'])
content_facet_attributes = response.get('content_facet_attributes')
self.assertIsNotNone(content_facet_attributes)
content_source_id = content_facet_attributes.get('content_source_id')
self.assertIsNotNone(content_source_id)
self.assertEqual(content_source_id, proxy.id)

@run_only_on('sat')
@tier2
@stubbed()
Expand Down