def test_positive_update_major_version(self): """Update an Operating System's major version. :id: 38a89dbe-6d1c-4602-a4c1-664425668de8 :expectedresults: Operating System major version is updated :CaseImportance: Critical """ os = make_os() # New value for major major = int(os['major-version']) + 1 OperatingSys.update({'id': os['id'], 'major': major}) os = OperatingSys.info({'id': os['id']}) assert int(os['major-version']) == major
def test_positive_update_name(self): """Positive update of operating system name :id: 49b655f7-ba9b-4bb9-b09d-0f7140969a40 :expectedresults: Operating System name is updated :CaseImportance: Critical """ os = make_os({'name': gen_alphanumeric()}) for new_name in valid_data_list(): with self.subTest(new_name): OperatingSys.update({'id': os['id'], 'name': new_name}) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['id'], os['id']) self.assertNotEqual(result['name'], os['name'])
def test_negative_update_name(self): """Negative update of system name :id: 4b18ff6d-7728-4245-a1ce-38e62c05f454 :expectedresults: Operating System name is not updated :CaseImportance: Critical """ os = make_os({'name': gen_alphanumeric()}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): OperatingSys.update({'id': os['id'], 'name': new_name}) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['name'], os['name'])
def test_bugzilla_1051557(self): """@test: Update an Operating System's major version. @feature: Operating System - Update @assert: Operating System major version is updated """ try: os = make_os() except CLIFactoryError as err: self.fail(err) # New value for major major = int(os['major-version']) + 1 result = OperatingSys.update({'id': os['id'], 'major': major}) self.assertEqual(result.return_code, 0, 'Failed to update activation key') self.assertEqual(len(result.stderr), 0, 'There should not be an error here') result = OperatingSys.info({ u'id': os['id'], }) self.assertEqual(result.return_code, 0, 'Failed to get info for OS') self.assertEqual(len(result.stderr), 0, 'There should not be an error here') self.assertEqual(int(result.stdout['major-version']), major, 'OS major version was not updated')
def test_negative_update_name(self, new_name): """Negative update of system name :id: 4b18ff6d-7728-4245-a1ce-38e62c05f454 :parametrized: yes :expectedresults: Operating System name is not updated :CaseImportance: Critical """ os = make_os({'name': gen_alphanumeric()}) with pytest.raises(CLIReturnCodeError): OperatingSys.update({'id': os['id'], 'name': new_name}) result = OperatingSys.info({'id': os['id']}) assert result['name'] == os['name']
def test_negative_update_1(self, test_data): """@test: Negative update of system name @feature: Operating System - Negative Update @assert: Operating System is not updated """ # "Unpacks" values from tuple orig_dict, updates_dict = test_data # Create a new object passing @test_data to factory method new_obj = make_os(orig_dict) # Update original data with new values updates_dict['id'] = new_obj['id'] orig_dict.update(updates_dict) # Now update the Foreman object result = OperatingSys.update(orig_dict) self.assertNotEqual(result.return_code, 0) self.assertGreater(len(result.stderr), 0) # OS should not have changed result = OperatingSys.info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertEqual(new_obj['name'], result.stdout['name'])
def test_bugzilla_1051557(self): """@test: Update an Operating System's major version. @feature: Operating System - Update @assert: Operating System major version is updated """ try: os = make_os() except CLIFactoryError as err: self.fail(err) # New value for major major = int(os['major-version']) + 1 result = OperatingSys.update( {'id': os['id'], 'major': major}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) result = OperatingSys.info({ u'id': os['id'], }) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertEqual(int(result.stdout['major-version']), major)
def test_bugzilla_1051557(self): """@test: Update an Operating System's major version. @feature: Operating System - Update @assert: Operating System major version is updated @bz: 1021557 """ try: os = make_os() except CLIFactoryError as err: self.fail(err) # New value for major major = int(os['major-version']) + 1 result = OperatingSys.update( {'id': os['id'], 'major': major}) self.assertEqual(result.return_code, 0, 'Failed to update activation key') self.assertEqual(len(result.stderr), 0, 'There should not be an error here') result = OperatingSys.info({ u'id': os['id'], }) self.assertEqual(result.return_code, 0, 'Failed to get info for OS') self.assertEqual(len(result.stderr), 0, 'There should not be an error here') self.assertEqual(int(result.stdout['major-version']), major, 'OS major version was not updated')
def test_positive_update_1(self, test_data): """ @test: Positive update of system name @feature: Operating System - Positive Update @assert: Operating System is updated and can be found """ # "Unpacks" values from tuple orig_dict, updates_dict = test_data # Create a new object passing @test_data to factory method new_obj = make_os(orig_dict) result = OperatingSys.info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual( len(result.stderr), 0, "There should not be an exception here") # Update original test_data with new values updates_dict['id'] = new_obj['id'] orig_dict.update(updates_dict) # Now update the Foreman object result = OperatingSys.update(orig_dict) self.assertEqual(result.return_code, 0, "Failed to update object") self.assertEqual( len(result.stderr), 0, "There should not be an exception here") result = OperatingSys.info({'id': new_obj['id']}) # Verify that standard values are correct self.assertEqual( new_obj['id'], result.stdout['id'], "IDs should match") self.assertNotEqual(result.stdout['name'], new_obj['name']) # There should be some attributes changed now self.assertNotEqual(new_obj, result.stdout, "Object should be updated")
def test_positive_update_name(self, new_name): """Positive update of operating system name :id: 49b655f7-ba9b-4bb9-b09d-0f7140969a40 :parametrized: yes :expectedresults: Operating System name is updated :CaseImportance: Critical """ os = make_os({'name': gen_alphanumeric()}) OperatingSys.update({'id': os['id'], 'name': new_name}) result = OperatingSys.info({'id': os['id']}) assert result['id'] == os['id'] assert result['name'] != os['name']
def test_negative_update_name(self): """Negative update of system name @feature: Operating System @assert: Operating System name is not updated """ os = make_os({'name': gen_alphanumeric()}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): OperatingSys.update({ 'id': os['id'], 'name': new_name, }) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['name'], os['name'])
def test_positive_update_name(self): """Positive update of operating system name @id: 49b655f7-ba9b-4bb9-b09d-0f7140969a40 @assert: Operating System name is updated """ os = make_os({'name': gen_alphanumeric()}) for new_name in valid_data_list(): with self.subTest(new_name): OperatingSys.update({ 'id': os['id'], 'name': new_name, }) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['id'], os['id'], ) self.assertNotEqual(result['name'], os['name'])
def test_negative_update_name(self): """Negative update of system name @id: 4b18ff6d-7728-4245-a1ce-38e62c05f454 @assert: Operating System name is not updated """ os = make_os({'name': gen_alphanumeric()}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): OperatingSys.update({ 'id': os['id'], 'name': new_name, }) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['name'], os['name'])
def test_positive_update_name(self): """@test: Positive update of operating system name @feature: Operating System @assert: Operating System name is updated """ os = make_os({'name': gen_alphanumeric()}) for new_name in valid_data_list(): with self.subTest(new_name): OperatingSys.update({ 'id': os['id'], 'name': new_name, }) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['id'], os['id'], ) self.assertNotEqual(result['name'], os['name'])
def test_positive_update_major_version(self): """@test: Update an Operating System's major version. @feature: Operating System @assert: Operating System major version is updated """ os = make_os() # New value for major major = int(os['major-version']) + 1 OperatingSys.update({ 'id': os['id'], 'major': major, }) os = OperatingSys.info({ 'id': os['id'], }) self.assertEqual(int(os['major-version']), major)
def test_positive_update_major_version(self): """Update an Operating System's major version. @id: 38a89dbe-6d1c-4602-a4c1-664425668de8 @assert: Operating System major version is updated """ os = make_os() # New value for major major = int(os['major-version']) + 1 OperatingSys.update({ 'id': os['id'], 'major': major, }) os = OperatingSys.info({ 'id': os['id'], }) self.assertEqual(int(os['major-version']), major)
def test_negative_update_1(self): """@test: Negative update of system name @feature: Operating System - Negative Update @assert: Operating System is not updated """ os = make_os({'name': gen_alphanumeric()}) for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): OperatingSys.update({ 'id': os['id'], 'name': new_name, }) result = OperatingSys.info({'id': os['id']}) self.assertEqual(result['name'], os['name'])
def test_positive_update_major_version(self): """Update an Operating System's major version. @feature: Operating System @assert: Operating System major version is updated """ os = make_os() # New value for major major = int(os['major-version']) + 1 OperatingSys.update({ 'id': os['id'], 'major': major, }) os = OperatingSys.info({ 'id': os['id'], }) self.assertEqual(int(os['major-version']), major)
def test_positive_update_major_version(self): """Update an Operating System's major version. @id: 38a89dbe-6d1c-4602-a4c1-664425668de8 @assert: Operating System major version is updated """ os = make_os() # New value for major major = int(os['major-version']) + 1 OperatingSys.update({ 'id': os['id'], 'major': major, }) os = OperatingSys.info({ 'id': os['id'], }) self.assertEqual(int(os['major-version']), major)
def test_positive_update_name(self): """Positive update of operating system name @feature: Operating System @assert: Operating System name is updated """ os = make_os({'name': gen_alphanumeric()}) for new_name in valid_data_list(): with self.subTest(new_name): OperatingSys.update({ 'id': os['id'], 'name': new_name, }) result = OperatingSys.info({'id': os['id']}) self.assertEqual( result['id'], os['id'], ) self.assertNotEqual(result['name'], os['name'])
def test_positive_update_parameters_attributes(self): """Update os-parameters-attributes to operating system :id: 5d566eea-b323-4128-9356-3bf39943e4d4 :BZ: 1713553 :expectedresults: Os-parameters-attributes are updated to Operating System """ param_name = gen_string('alpha') param_value = gen_string('alpha') os_id = make_os()['id'] OperatingSys.update({ 'id': os_id, 'os-parameters-attributes': 'name={}, value={}'.format(param_name + '\\', param_value), }) os = OperatingSys.info({'id': os_id}, output_format='json') assert param_name == os['parameters'][0]['name'] assert param_value == os['parameters'][0]['value']
def test_bugzilla_1051557(self): """ @test: Update an Operating System's major version. @feature: Operating System - Update @assert: Operating System major version is updated @bz: 1021557 """ new_obj = make_os() os_info = OperatingSys.info({'id': new_obj['id']}) self.assertEqual(new_obj['name'], os_info.stdout['name']) # New value for major major = int(new_obj['major']) + 1 result = OperatingSys.update( {'id': os_info.stdout['id'], 'major': major}) self.assertEqual(result.return_code, 0) result = OperatingSys.info({'id': result.stdout['id']}) self.assertEqual(result.return_code, 0) # this will check the updation of major == 3 self.assertEqual(major, result.stdout['major'])
def test_negative_update_1(self, test_data): """@test: Negative update of system name @feature: Operating System - Negative Update @assert: Operating System is not updated """ # "Unpacks" values from tuple orig_dict, updates_dict = test_data # Create a new object passing @test_data to factory method new_obj = make_os(orig_dict) result = OperatingSys.info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") # Update original data with new values updates_dict['id'] = new_obj['id'] orig_dict.update(updates_dict) # Now update the Foreman object result = OperatingSys.update(orig_dict) self.assertNotEqual(result.return_code, 0, "Update command should have failed") self.assertGreater(len(result.stderr), 0, "There should be an exception here") # OS should not have changed result = OperatingSys.info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") self.assertEqual(new_obj['name'], result.stdout['name'], "Name should not be updated")
def test_positive_update_1(self, test_data): """@test: Positive update of system name @feature: Operating System - Positive Update @assert: Operating System is updated and can be found """ # "Unpacks" values from tuple orig_dict, updates_dict = test_data # Create a new object passing @test_data to factory method new_obj = make_os(orig_dict) result = OperatingSys.info({'id': new_obj['id']}) self.assertEqual(result.return_code, 0, "Failed to create object") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") # Update original test_data with new values updates_dict['id'] = new_obj['id'] orig_dict.update(updates_dict) # Now update the Foreman object result = OperatingSys.update(orig_dict) self.assertEqual(result.return_code, 0, "Failed to update object") self.assertEqual(len(result.stderr), 0, "There should not be an exception here") result = OperatingSys.info({'id': new_obj['id']}) # Verify that standard values are correct self.assertEqual(new_obj['id'], result.stdout['id'], "IDs should match") self.assertNotEqual(result.stdout['name'], new_obj['name']) # There should be some attributes changed now self.assertNotEqual(new_obj, result.stdout, "Object should be updated")
def test_positive_create_with_synced_content(self): """Check if hostgroup with synced kickstart repository can be created :id: 7c51ac72-359c-488a-8658-88b5a94d7e7a :customerscenario: true :expectedresults: Hostgroup should be created and has proper installation content id present :BZ: 1415707 :CaseLevel: Integration """ # Check whether path to kickstart media is set if settings.rhel6_os is None: raise ValueError( 'Installation media path is not set in properties file') # Common entities org = make_org() lce = make_lifecycle_environment({'organization-id': org['id']}) product = make_product({'organization-id': org['id']}) repo = make_repository({ u'url': settings.rhel6_os, u'product-id': product['id'], u'content-type': u'yum', }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({ 'organization-id': org['id'], 'repository-ids': [repo['id']], }) ContentView.publish({'id': cv['id']}) cv = ContentView.info({'id': cv['id']}) cvv = cv['versions'][0] ContentView.version_promote({ 'id': cvv['id'], 'to-lifecycle-environment-id': lce['id'], }) # Get the Partition table ID ptable = PartitionTable.info({'name': DEFAULT_PTABLE}) # Get the arch ID arch = Architecture.list( {'search': 'name={0}'.format(DEFAULT_ARCHITECTURE)})[0] # Get the OS ID os = OperatingSys.list({ 'search': 'name="RedHat" AND major="{0}" OR major="{1}"'.format( RHEL_6_MAJOR_VERSION, RHEL_7_MAJOR_VERSION) })[0] # Update the OS with found arch and ptable OperatingSys.update({ 'id': os['id'], 'architectures': arch['name'], 'partition-tables': ptable['name'], }) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # Search for proper installation repository id synced_repo = Repository.list({ 'content-view-version-id': cvv['id'], 'organization-id': org['id'], 'environment-id': lce['id'], })[0] hostgroup = make_hostgroup({ 'lifecycle-environment-id': lce['id'], 'puppet-proxy-id': proxy['id'], 'puppet-ca-proxy-id': proxy['id'], 'content-source-id': proxy['id'], 'content-view-id': cv['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'operatingsystem-id': os['id'], 'kickstart-repository-id': synced_repo['id'], }) hg = HostGroup.info({'id': hostgroup['id']}, output_format='json') self.assertEqual(hg['kickstart-repository']['id'], synced_repo['id'])
def test_positive_create_with_synced_content(self): """Check if hostgroup with synced kickstart repository can be created :id: 7c51ac72-359c-488a-8658-88b5a94d7e7a :customerscenario: true :expectedresults: Hostgroup should be created and has proper installation content id present :BZ: 1415707 :CaseLevel: Integration """ # Check whether path to kickstart media is set if settings.rhel6_os is None: raise ValueError( 'Installation media path is not set in properties file') # Common entities org = make_org() lce = make_lifecycle_environment({'organization-id': org['id']}) product = make_product({'organization-id': org['id']}) repo = make_repository({ u'url': settings.rhel6_os, u'product-id': product['id'], u'content-type': u'yum', }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({ 'organization-id': org['id'], 'repository-ids': [repo['id']], }) ContentView.publish({'id': cv['id']}) cv = ContentView.info({'id': cv['id']}) cvv = cv['versions'][0] ContentView.version_promote({ 'id': cvv['id'], 'to-lifecycle-environment-id': lce['id'], }) # Get the Partition table ID ptable = PartitionTable.info({'name': DEFAULT_PTABLE}) # Get the arch ID arch = Architecture.list({ 'search': 'name={0}'.format(DEFAULT_ARCHITECTURE)})[0] # Get the OS ID os = OperatingSys.list({ 'search': 'name="RedHat" AND major="{0}" OR major="{1}"'.format( RHEL_6_MAJOR_VERSION, RHEL_7_MAJOR_VERSION) })[0] # Update the OS with found arch and ptable OperatingSys.update({ 'id': os['id'], 'architectures': arch['name'], 'partition-tables': ptable['name'], }) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # Search for proper installation repository id synced_repo = Repository.list({ 'content-view-version-id': cvv['id'], 'organization-id': org['id'], 'environment-id': lce['id'], })[0] hostgroup = make_hostgroup({ 'lifecycle-environment-id': lce['id'], 'puppet-proxy-id': proxy['id'], 'puppet-ca-proxy-id': proxy['id'], 'content-source-id': proxy['id'], 'content-view-id': cv['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'operatingsystem-id': os['id'], 'kickstart-repository-id': synced_repo['id'], }) hg = HostGroup.info({'id': hostgroup['id']}, output_format='json') self.assertEqual( hg['operating-system']['kickstart_repository_id'], synced_repo['id'] )