def test_add_docker_repo_to_content_view(self, name): """@Test: Add one Docker-type repository to a non-composite content view @Assert: A repository is created with a Docker repository and the product is added to a non-composite content view @Feature: Docker """ upstream_name = u'busybox' prod_id = entities.Product( organization=self.org_id).create_json()['id'] repo_id = _create_repository(prod_id, name, upstream_name)['id'] real_attrs = entities.Repository(id=repo_id).read_json() self.assertEqual(real_attrs['name'], name) self.assertEqual(real_attrs['docker_upstream_name'], upstream_name) self.assertEqual(real_attrs['content_type'], u'docker') # Create content view and associate docker repo content_view = entities.ContentView(organization=self.org_id, composite=False).create_json() _add_repo_to_content_view(repo_id, content_view['id']) new_attrs = entities.ContentView(id=content_view['id']).read_json() self.assertIn(repo_id, new_attrs['repository_ids'])
def test_publish_once_docker_repo_content_view(self): """@Test: Add Docker-type repository to content view and publish it once. @Assert: One repository is created with a Docker image and the product is added to a content view which is then published only once. @Feature: Docker """ prod_id = entities.Product( organization=self.org_id).create_json()['id'] repo_id = _create_repository(prod_id)['id'] content_view = entities.ContentView(organization=self.org_id, composite=False).create_json() _add_repo_to_content_view(repo_id, content_view['id']) new_attrs = entities.ContentView(id=content_view['id']).read_json() self.assertIn(repo_id, new_attrs['repository_ids']) # Not published yet? self.assertIsNone(new_attrs['last_published']) self.assertEqual(new_attrs['next_version'], 1) # Publish it... self.assertTrue(_publish_content_view(content_view['id'])) # ... and check that it was indeed published new_attrs = entities.ContentView(id=content_view['id']).read_json() self.assertIsNotNone(new_attrs['last_published']) self.assertGreater(new_attrs['next_version'], 1)
def test_positive_create_3(self, name): """@Test: Create empty content-view with random names. @Assert: Content-view is created and had random name. @Feature: ContentView """ content_view = entities.ContentView(name=name).create()['id'] attrs = entities.ContentView(id=content_view).read_json() self.assertEqual(attrs['name'], name)
def test_positive_create_2(self): """@Test: Create an empty composite content view. @Assert: Creation succeeds and content-view is composite. @Feature: ContentView """ content_view = entities.ContentView(id=entities.ContentView( composite=True).create()['id']) self.assertTrue(content_view.read_json()['composite'])
def test_positive_create_4(self, description): """@Test: Create empty content view with random description. @Assert: Content-view is created and has random description. @Feature: ContentView """ content_view = entities.ContentView( description=description).create()['id'] attrs = entities.ContentView(id=content_view).read_json() self.assertEqual(attrs['description'], description)
def test_positive_promote_1(self): """@Test: Promote a content view version ``REPEAT`` times. @Assert: The content view version points to ``REPEAT + 1`` lifecycle environments after the promotions. @Feature: ContentView """ content_view = entities.ContentView(organization=self.org.id) content_view.id = content_view.create_json()['id'] response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Promote the content view version several times. cvv = entities.ContentViewVersion( id=content_view.read_json()['versions'][0]['id'] # only one ver ) for _ in range(REPEAT): lc_env_id = entities.LifecycleEnvironment( organization=self.org.id).create_json()['id'] response = cvv.promote(lc_env_id) humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Does it show up in the correct number of lifecycle environments? self.assertEqual( len(content_view.read_json()['versions'][0]['environment_ids']), REPEAT + 1)
def test_positive_publish_3(self): """@Test: Publish a content view that has puppet modules several times. @Assert: The puppet module is referenced fromt he content view, the content view can be published several times, and each version references the puppet module. @Feature: ContentView """ content_view = entities.ContentView(organization=self.org.id) content_view.id = content_view.create_json()['id'] puppet_module = content_view.available_puppet_modules()['results'][0] content_view.add_puppet_module(puppet_module['author'], puppet_module['name']) # Check that the puppet module is referenced. self.assertEqual(len(content_view.read_json()['puppet_modules']), 1) # Publish the content view several times and check that each version # has the puppet module added above. for _ in range(REPEAT): response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) for cvv_id in ( # content view version ID version['id'] for version in content_view.read_json()['versions']): cvv = entities.ContentViewVersion(id=cvv_id) self.assertEqual(len(cvv.read_json()['puppet_modules']), 1)
def test_positive_publish_2(self): """@Test: Give a content view yum packages and publish it repeatedly. @Assert: The yum repo is referenced from the content view, the content view can be published several times, and each content view version has at least one package. @Feature: ContentView """ content_view = entities.ContentView(organization=self.org.id) content_view.id = content_view.create_json()['id'] content_view.set_repository_ids([self.yum_repo.id]) # Check that the yum repo is referenced. self.assertEqual(len(content_view.read_json()['repositories']), 1) # Publish the content view several times and check that each version # has some software packages. for _ in range(REPEAT): response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) for cvv_id in ( # content view version ID version['id'] for version in content_view.read_json()['versions']): cvv = entities.ContentViewVersion(id=cvv_id) self.assertGreater(cvv.read_json()['package_count'], 0)
def test_add_multiple_docker_repos_to_composite_content_view(self): """@Test: Add multiple Docker-type repositories to a composite content view. @Assert: One repository is created with a Docker image and the product is added to a random number of content views which are then added to a composite content view. @Feature: Docker """ prod_ids = [] cv_version_ids = [] for _ in range(randint(1, 5)): prod_ids.append( entities.Product(organization=self.org_id).create_json()['id']) for prod_id in prod_ids: repo_id = _create_repository(prod_id)['id'] # Create content view and associate docker repo content_view = entities.ContentView(organization=self.org_id, composite=False).create_json() _add_repo_to_content_view(repo_id, content_view['id']) new_attrs = entities.ContentView(id=content_view['id']).read_json() self.assertIn(repo_id, new_attrs['repository_ids']) # Publish it... self.assertTrue(_publish_content_view(content_view['id'])) # ... and grab its version ID (there should only be one version) new_attrs = entities.ContentView(id=content_view['id']).read_json() cv_version_ids.append(new_attrs['versions'][0]['id']) # Create composite content view and associate content view to # it comp_content_view_id = entities.ContentView( organization=self.org_id, composite=True).create_json()['id'] for version_id in cv_version_ids: _add_content_view_to_composite_view(comp_content_view_id, version_id) new_attrs = entities.ContentView( id=comp_content_view_id).read_json() self.assertIn(version_id, new_attrs['component_ids'])
def test_subscribe_system_to_cv(self): """@Test: Subscribe a system to a content view. @Feature: ContentView @Assert: It is possible to create a system and set its 'content_view_id' attribute. """ # organization # ├── lifecycle environment # └── content view org = entities.Organization() org.id = org.create()['id'] lifecycle_env = entities.LifecycleEnvironment(organization=org.id) lifecycle_env.id = lifecycle_env.create()['id'] content_view = entities.ContentView(organization=org.id) content_view.id = content_view.create()['id'] # Publish the content view. response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Get the content view version's ID. response = client.get( entities.ContentViewVersion().path(), auth=get_server_credentials(), data={u'content_view_id': content_view.id}, verify=False, ) response.raise_for_status() results = response.json()['results'] self.assertEqual(len(results), 1) cv_version = entities.ContentViewVersion(id=results[0]['id']) # Promote the content view version. response = cv_version.promote(environment_id=lifecycle_env.id) humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual('success', response['result'], humanized_errors) # Create a system that is subscribed to the published and promoted # content view. Associating this system with the organization and # environment created above is not particularly important, but doing so # means a shorter test where fewer entities are created, as # System.organization and System.environment are required attributes. system_attrs = entities.System( content_view=content_view.id, environment=lifecycle_env.id, organization=org.id, ).create() # See BZ #1151240 self.assertEqual(system_attrs['content_view_id'], content_view.id) self.assertEqual(system_attrs['environment']['id'], lifecycle_env.id) self.assertEqual(system_attrs['organization_id'], org.id)
def _publish_content_view(cv_id): """Publishes an existing content view. :param int cv_id: The ID for an existing content view. :return: A boolean indicating whether the publication worked or not. """ task_status = entities.ContentView(id=cv_id).publish() return task_status['result'] == u'success'
def _add_repo_to_content_view(repo_id, cv_id): """Adds a repository to an existing content view. :param int repo_id: The ID for an existing repository. :param int cv_id: The ID for an existing content view. """ client.put(entities.ContentView(id=cv_id).path(), auth=get_server_credentials(), verify=False, data={ u'repository_ids': [repo_id] }).raise_for_status()
def _add_content_view_to_composite_view(cv_id, cv_version_id): """Adds a published content view to a composite content view. :param int cv_id: The ID for an existing composite content view. :param int cv_version_id: The ID for a published non-composite content view. """ client.put(entities.ContentView(id=cv_id).path(), auth=get_server_credentials(), verify=False, data={ u'component_ids': [cv_version_id] }).raise_for_status()
def test_add_docker_repo_to_composite_content_view(self, name): """@Test: Add one Docker-type repository to a composite content view @Assert: A repository is created with a Docker repository and the product is added to a content view which is then added to a composite content view. @Feature: Docker """ prod_id = entities.Product( organization=self.org_id).create_json()['id'] repo_id = _create_repository(prod_id, name)['id'] # Create content view and associate docker repo content_view = entities.ContentView(organization=self.org_id, composite=False).create_json() _add_repo_to_content_view(repo_id, content_view['id']) new_attrs = entities.ContentView(id=content_view['id']).read_json() self.assertIn(repo_id, new_attrs['repository_ids']) # Publish it... self.assertTrue(_publish_content_view(content_view['id'])) # ... and grab its version ID (there should only be one version) new_attrs = entities.ContentView(id=content_view['id']).read_json() version_id = new_attrs['versions'][0]['id'] # Create composite content view and associate content view to # it comp_content_view_id = entities.ContentView( organization=self.org_id, composite=True).create_json()['id'] _add_content_view_to_composite_view(comp_content_view_id, version_id) new_attrs = entities.ContentView(id=comp_content_view_id).read_json() self.assertIn(version_id, new_attrs['component_ids'])
def test_add_synced_docker_repo_to_content_view(self): """@Test: Create and sync a Docker-type repository @Assert: A repository is created with a Docker repository and it is synchronized. @Feature: Docker """ prod_id = entities.Product( organization=self.org_id).create_json()['id'] repo_id = _create_repository(prod_id)['id'] task = entities.Repository(id=repo_id).sync() self.assertEqual(u'success', task['result'], task) attrs = entities.Repository(id=repo_id).read_json() self.assertGreaterEqual(attrs[u'content_counts'][u'docker_image'], 1) # Create content view and associate docker repo content_view = entities.ContentView(organization=self.org_id, composite=False).create_json() _add_repo_to_content_view(repo_id, content_view['id']) new_attrs = entities.ContentView(id=content_view['id']).read_json() self.assertIn(repo_id, new_attrs['repository_ids'])
def test_positive_publish_1(self): """@Test: Publish a content view several times. @Assert: Content view has the correct number of versions after each promotion. @Feature: ContentView """ content_view = entities.ContentView() content_view.id = content_view.create_json()['id'] for _ in range(REPEAT): response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) self.assertEqual(len(content_view.read_json()['versions']), REPEAT)
def test_positive_promote_3(self): """@Test: Give a content view a puppet module, publish it once and promote the content view version ``REPEAT + 1`` times. @Assert: The content view has one puppet module, the content view version is in ``REPEAT + 1`` lifecycle environments and it has one puppet module. @Feature: ContentView """ content_view = entities.ContentView(organization=self.org.id) content_view.id = content_view.create_json()['id'] puppet_module = content_view.available_puppet_modules()['results'][0] content_view.add_puppet_module(puppet_module['author'], puppet_module['name']) response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Promote the content view version. cvv = entities.ContentViewVersion( id=content_view.read_json()['versions'][0]['id'] # only one ver ) for _ in range(REPEAT): lc_env_id = entities.LifecycleEnvironment( organization=self.org.id).create_json()['id'] response = cvv.promote(lc_env_id) humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Everything's done. Check some content view attributes... cv_attrs = content_view.read_json() self.assertEqual(len(cv_attrs['versions']), 1) self.assertEqual(len(cv_attrs['puppet_modules']), 1) # ...and some content view version attributes. cvv_attrs = entities.ContentViewVersion( id=cv_attrs['versions'][0]['id']).read_json() self.assertEqual(len(cvv_attrs['environments']), REPEAT + 1) self.assertEqual(len(cvv_attrs['puppet_modules']), 1)
def test_positive_promote_2(self): """@Test: Give a content view a yum repo, publish it once and promote the content view version ``REPEAT + 1`` times. @Assert: The content view has one repository, the content view version is in ``REPEAT + 1`` lifecycle environments and it has at least one package. @Feature: ContentView """ content_view = entities.ContentView(organization=self.org.id) content_view.id = content_view.create_json()['id'] content_view.set_repository_ids([self.yum_repo.id]) response = content_view.publish() humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Promote the content view version. cvv = entities.ContentViewVersion( id=content_view.read_json()['versions'][0]['id'] # only one ver ) for _ in range(REPEAT): lc_env_id = entities.LifecycleEnvironment( organization=self.org.id).create_json()['id'] response = cvv.promote(lc_env_id) humanized_errors = response['humanized']['errors'] _check_bz_1186432(humanized_errors) self.assertEqual(response['result'], 'success', humanized_errors) # Everything's done - check some content view attributes... cv_attrs = content_view.read_json() self.assertEqual(len(cv_attrs['repositories']), 1) self.assertEqual(len(cv_attrs['versions']), 1) # ...and some content view version attributes. cvv_attrs = entities.ContentViewVersion( id=cv_attrs['versions'][0]['id']).read_json() self.assertEqual(len(cvv_attrs['environments']), REPEAT + 1) self.assertGreater(cvv_attrs['package_count'], 0)
def test_end_to_end(self): """@Test: Perform end to end smoke tests using RH repos. 1. Create new organization and environment 2. Clone and upload manifest 3. Sync a RedHat repository 4. Create content-view 5. Add repository to contet-view 6. Promote/publish content-view 7. Create an activation-key 8. Add product to activation-key 9. Create new virtualmachine 10. Pull rpm from Foreman server and install on client 11. Register client with foreman server using activation-key 12. Install rpm on client @Feature: Smoke test @Assert: All tests should succeed and Content should be successfully fetched by client """ product = "Red Hat Enterprise Linux Server" reposet = ("Red Hat Enterprise Virtualization Agents " "for RHEL 6 Server (RPMs)") repo = ("Red Hat Enterprise Virtualization Agents for RHEL 6 Server " "RPMs x86_64 6Server") activation_key_name = gen_string('alpha') # step 1.1: Create a new organization org = entities.Organization().create() # step 1.2: Create new lifecycle environments lifecycle_env = entities.LifecycleEnvironment( organization=org['id'] ).create() # step 2: Upload manifest manifest_path = manifests.clone() task = entities.Organization( id=org['id'] ).upload_manifest(path=manifest_path) self.assertEqual( u'success', task['result'], task['humanized']['errors'] ) # step 3.1: Enable RH repo and fetch repository_id repo_id = utils.enable_rhrepo_and_fetchid( basearch="x86_64", org_id=org['id'], product=product, repo=repo, reposet=reposet, releasever="6Server", ) # step 3.2: sync repository task_result = entities.Repository(id=repo_id).sync()['result'] self.assertEqual( task_result, u'success', u" Error while syncing repository '{0}' and state is {1}." .format(repo, task_result)) # step 4: Create content view content_view = entities.ContentView(organization=org['id']).create() # step 5: Associate repository to new content view response = client.put( entities.ContentView(id=content_view['id']).path(), {u'repository_ids': [repo_id]}, auth=get_server_credentials(), verify=False, ) response.raise_for_status() # step 6.1: Publish content view task_status = entities.ContentView(id=content_view['id']).publish() self.assertEqual( task_status['result'], u'success', u"Error publishing content-view {0} and state is {1}." .format(content_view['name'], task_status['result'])) # step 6.2: Promote content view to lifecycle_env content_view = entities.ContentView(id=content_view['id']).read_json() self.assertEqual(len(content_view['versions']), 1) task_status = entities.ContentViewVersion( id=content_view['versions'][0]['id'] ).promote(lifecycle_env['id']) self.assertEqual( task_status['result'], u'success', u"Error promoting {0} to {1} and state is {2}." .format(content_view['name'], lifecycle_env['name'], task_status['result'])) # step 7: Create activation key ak_id = entities.ActivationKey( name=activation_key_name, environment=lifecycle_env['id'], organization=org['id'], content_view=content_view['id'], ).create_json()['id'] # Walk through the list of subscriptions. Find the "Red Hat Employee # Subscription" and attach it to the just-created activation key. for subscription in entities.Organization(id=org['id']).subscriptions(): if subscription['product_name'] == "Red Hat Employee Subscription": # 'quantity' must be 1, not subscription['quantity']. Greater # values produce this error: "RuntimeError: Error: Only pools # with multi-entitlement product subscriptions can be added to # the activation key with a quantity greater than one." entities.ActivationKey(id=ak_id).add_subscriptions({ 'quantity': 1, 'subscription_id': subscription['id'], }) break # Create VM package_name = "python-kitchen" with VirtualMachine(distro='rhel66') as vm: # Download and Install rpm result = vm.run( "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/" .format(conf.properties['main.server.hostname']) ) self.assertEqual( result.return_code, 0, "failed to fetch katello-ca rpm: {0}, return code: {1}" .format(result.stderr, result.return_code) ) result = vm.run( 'rpm -i katello-ca-consumer*.noarch.rpm' ) self.assertEqual( result.return_code, 0, "failed to install katello-ca rpm: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Register client with foreman server using activation-key result = vm.run( u'subscription-manager register --activationkey {0} ' '--org {1} --force' .format(activation_key_name, org['label']) ) self.assertEqual( result.return_code, 0, "failed to register client:: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Enable Red Hat Enterprise Virtualization Agents repo via cli # As the below repo is disabled by default under ak's prd-content result = vm.run( 'subscription-manager repos --enable ' 'rhel-6-server-rhev-agent-rpms' ) self.assertEqual( result.return_code, 0, "Enabling repo failed: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Install contents from sat6 server result = vm.run('yum install -y {0}'.format(package_name)) self.assertEqual( result.return_code, 0, "Package install failed: {0} and return code: {1}" .format(result.stderr, result.return_code) ) # Verify if package is installed by query it result = vm.run('rpm -q {0}'.format(package_name)) self.assertIn(package_name, result.stdout[0])
def test_smoke(self): """@Test: Check that basic content can be created 1. Create a new user with admin permissions 2. Using the new user from above: 1. Create a new organization 2. Create two new lifecycle environments 3. Create a custom product 4. Create a custom YUM repository 5. Create a custom PUPPET repository 6. Synchronize both custom repositories 7. Create a new content view 8. Associate both repositories to new content view 9. Publish content view 10. Promote content view to both lifecycles 11. Create a new libvirt compute resource 12. Create a new subnet 13. Create a new domain 14. Create a new hostgroup and associate previous entities to it @Feature: Smoke Test @Assert: All entities are created and associated. """ # prep work # # FIXME: Use a larger charset when authenticating users. # # It is possible to create a user with a wide range of characters. (see # the "User" entity). However, Foreman supports only HTTP Basic # authentication, and the requests lib enforces the latin1 charset in # this auth mode. We then further restrict ourselves to the # alphanumeric charset, because Foreman complains about incomplete # multi-byte chars when latin1 chars are used. # login = gen_string('alphanumeric') password = gen_string('alphanumeric') # step 1: Create a new user with admin permissions entities.User(admin=True, login=login, password=password).create() # step 2.1: Create a new organization org = entities.Organization().create(auth=(login, password)) # step 2.2: Create 2 new lifecycle environments le1 = entities.LifecycleEnvironment(organization=org['id']).create() le2 = entities.LifecycleEnvironment( organization=org['id'], prior=le1['id']).create() # step 2.3: Create a custom product prod = entities.Product(organization=org['id']).create() # step 2.4: Create custom YUM repository repo1 = entities.Repository( product=prod['id'], content_type=u'yum', url=GOOGLE_CHROME_REPO ).create() # step 2.5: Create custom PUPPET repository repo2 = entities.Repository( product=prod['id'], content_type=u'puppet', url=FAKE_0_PUPPET_REPO ).create() # step 2.6: Synchronize both repositories for repo in [repo1, repo2]: response = client.post( entities.Repository(id=repo['id']).path('sync'), { u'ids': [repo['id']], u'organization_id': org['id'] }, auth=get_server_credentials(), verify=False, ).json() self.assertGreater( len(response['id']), 1, u"Was not able to fetch a task ID.") task_status = entities.ForemanTask(id=response['id']).poll() self.assertEqual( task_status['result'], u'success', u"Sync for repository {0} failed.".format(repo['name'])) # step 2.7: Create content view content_view = entities.ContentView(organization=org['id']).create() # step 2.8: Associate YUM repository to new content view response = client.put( entities.ContentView(id=content_view['id']).path(), auth=get_server_credentials(), verify=False, data={u'repository_ids': [repo1['id']]}) # Fetch all available puppet modules puppet_mods = client.get( entities.ContentView(id=content_view['id']).path( 'available_puppet_module_names'), auth=get_server_credentials(), verify=False).json() self.assertGreater( puppet_mods['results'], 0, u"No puppet modules were found") # Select a random puppet module from the results puppet_mod = random.choice(puppet_mods['results']) # ... and associate it to the content view path = entities.ContentView(id=content_view['id']).path( 'content_view_puppet_modules') response = client.post( path, auth=get_server_credentials(), verify=False, data={u'name': puppet_mod['module_name']}) self.assertEqual( response.status_code, httplib.OK, status_code_error(path, httplib.OK, response) ) self.assertEqual( response.json()['name'], puppet_mod['module_name'], ) # step 2.9: Publish content view task_status = entities.ContentView(id=content_view['id']).publish() self.assertEqual( task_status['result'], u'success', u"Publishing {0} failed.".format(content_view['name'])) # step 2.10: Promote content view to both lifecycles content_view = entities.ContentView(id=content_view['id']).read_json() self.assertEqual( len(content_view['versions']), 1, u'There should only be 1 version published.') self.assertEqual( len(content_view['versions'][0]['environment_ids']), 1, u"Content view should be present on 1 lifecycle only") task_status = entities.ContentViewVersion( id=content_view['versions'][0]['id'] ).promote(le1['id']) self.assertEqual( task_status['result'], u'success', u"Promoting {0} to {1} failed.".format( content_view['name'], le1['name'])) # Check that content view exists in 2 lifecycles content_view = entities.ContentView(id=content_view['id']).read_json() self.assertEqual( len(content_view['versions']), 1, u'There should only be 1 version published.') self.assertEqual( len(content_view['versions'][0]['environment_ids']), 2, u"Content view should be present on 2 lifecycles only") task_status = entities.ContentViewVersion( id=content_view['versions'][0]['id'] ).promote(le2['id']) self.assertEqual( task_status['result'], u'success', u"Promoting {0} to {1} failed.".format( content_view['name'], le2['name'])) # Check that content view exists in 2 lifecycles content_view = entities.ContentView(id=content_view['id']).read_json() self.assertEqual( len(content_view['versions']), 1, u'There should only be 1 version published.') self.assertEqual( len(content_view['versions'][0]['environment_ids']), 3, u"Content view should be present on 3 lifecycle only") # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host = entities.System( content_view=content_view['id'], environment=le2['id'] ).create() # Check that content view matches what we passed self.assertEqual( content_host['content_view_id'], content_view['id'], u"Content views do not match." ) # Check that lifecycle environment matches self.assertEqual( content_host['environment']['id'], le2['id'], u"Environments do not match." )
def setUpClass(cls): # noqa """Create a content view.""" cls.content_view = entities.ContentView( id=entities.ContentView().create()['id'])