def test_positive_update_capsule(self): """Update location with new capsule @id: 2786146f-f466-4ed8-918a-5f46806558e2 @Assert: Location updated successfully and has correct capsule assigned @CaseLevel: Integration """ proxy_id_1 = make_proxy()['id'] proxy_id_2 = make_proxy()['id'] # Add capsules to cleanup list self.addCleanup(capsule_cleanup, proxy_id_1) self.addCleanup(capsule_cleanup, proxy_id_2) proxy = entities.SmartProxy(id=proxy_id_1).read() location = entities.Location(smart_proxy=[proxy]).create() # Add location to cleanup list self.addCleanup(location_cleanup, location.id) new_proxy = entities.SmartProxy(id=proxy_id_2).read() location.smart_proxy = [new_proxy] location = location.update(['smart_proxy']) self.assertEqual(location.smart_proxy[0].id, new_proxy.id) self.assertEqual(location.smart_proxy[0].read().name, new_proxy.name)
def test_redmine_3875(self): """ @Test: Proxy creation with random URL @Feature: Smart Proxy @Assert: Proxy is not created """ # Create a random proxy with self.assertRaises(Exception): make_proxy()
def test_redmine_3875(self): """ @Test: Proxy creation with random URL @Feature: Smart Proxy @Assert: Proxy is not created """ # Create a random proxy with self.assertRaises(Exception): make_proxy( {'url': 'http://%s:%s' % (generate_string('alpha', 6), generate_string('numeric', 4))})
def test_negative_create_with_url(self): """Proxy creation with random URL @id: 9050b362-c710-43ba-9d77-7680b8f9ed8c @Assert: Proxy is not created """ # Create a random proxy with self.assertRaises(CLIFactoryError): make_proxy({ u'url': u'http://{0}:{1}'.format( gen_string('alpha', 6), gen_string('numeric', 4)), })
def test_positive_update_capsule(self): """Update location with new capsule @Assert: Location updated successfully and has correct capsule assigned @Feature: Location - Update """ proxy = entities.SmartProxy(id=make_proxy()['id']).search()[0] location = entities.Location(smart_proxy=[proxy]).create() new_proxy = entities.SmartProxy(id=make_proxy()['id']).search()[0] location.smart_proxy = [new_proxy] location = location.update(['smart_proxy']) self.assertEqual(location.smart_proxy[0].id, new_proxy.id) self.assertEqual(location.smart_proxy[0].read().name, new_proxy.name)
def test_negative_create_with_url(self): """Proxy creation with random URL @Feature: Smart Proxy @Assert: Proxy is not created """ # Create a random proxy with self.assertRaises(CLIFactoryError): make_proxy({ u'url': u'http://{0}:{1}'.format( gen_string('alpha', 6), gen_string('numeric', 4)), })
def test_redmine_3875(self): """@Test: Proxy creation with random URL @Feature: Smart Proxy @Assert: Proxy is not created """ # Create a random proxy with self.assertRaises(Exception): make_proxy({ u'url': u'http://{0}:{1}'.format( gen_string('alpha', 6), gen_string('numeric', 4)), })
def test_positive_remove_capsule_by_id(self): """Remove a capsule from organization by its id :id: 98681f4f-a5e2-44f6-8879-d23ad90b4c59 :expectedresults: Capsule is removed from the org :CaseLevel: Integration """ loc = make_location() proxy = make_proxy() # Add capsule and location to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(location_cleanup, loc['id']) Location.add_smart_proxy({ 'id': loc['id'], 'smart-proxy-id': proxy['id'], }) Location.remove_smart_proxy({ 'id': loc['id'], 'smart-proxy-id': proxy['id'], }) loc = Location.info({'id': loc['id']}) self.assertNotIn(proxy['name'], loc['smart-proxies'])
def test_positive_remove_capsule_by_name(self): """Remove a capsule from organization by its name :id: 91dcafbe-5f52-48af-b5c7-9319b2929f5a :expectedresults: Capsule is removed from the org :CaseLevel: Integration """ loc = make_location() proxy = make_proxy() # Add capsule and location to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(location_cleanup, loc['id']) Location.add_smart_proxy({ 'name': loc['name'], 'smart-proxy': proxy['name'], }) Location.remove_smart_proxy({ 'name': loc['name'], 'smart-proxy': proxy['name'], }) loc = Location.info({'name': loc['name']}) self.assertNotIn(proxy['name'], loc['smart-proxies'])
def test_positive_remove_capsule_by_id(self): """Remove a capsule from organization by its id @id: 71af64ec-5cbb-4dd8-ba90-652e302305ec @Assert: Capsule is removed from the org @CaseLevel: Integration """ org = make_org() proxy = make_proxy() # Add capsule and org to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'id': org['id'], 'smart-proxy-id': proxy['id'], }) Org.remove_smart_proxy({ 'id': org['id'], 'smart-proxy-id': proxy['id'], }) org = Org.info({'id': org['id']}) self.assertNotIn(proxy['name'], org['smart-proxies'])
def test_positive_remove_capsule_by_name(self): """Remove a capsule from organization by its name @id: f56eaf46-fef5-4b52-819f-e30e61f0ec4a @Assert: Capsule is removed from the org @CaseLevel: Integration """ org = make_org() proxy = make_proxy() # Add capsule and org to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) Org.remove_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org = Org.info({'name': org['name']}) self.assertNotIn(proxy['name'], org['smart-proxies'])
def test_positive_update_content_source(self): """Update hostgroup's content source :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual( hostgroup['content-source']['name'], new_content_source['name'])
def test_add_smartproxy(self): "Adds a smartproxy to an org" org_result = make_org() proxy_result = make_proxy() return_value = Org().add_proxy({ 'name': org_result['name'], 'proxy': proxy_result['name']}) self.assertTrue(return_value.return_code, 0) self.assertFalse(return_value.stderr)
def test_refresh_refresh_features_by_id(self): """@Test: Refresh smart proxy features, search for proxy by id @Feature: Smart Proxy @Assert: Proxy features are refreshed """ proxy = make_proxy() Proxy.refresh_features({u'id': proxy['id']})
def test_proxy_refresh_features_by_name(self): """@Test: Refresh smart proxy features, search for proxy by name @Feature: Smart Proxy @Assert: Proxy features are refreshed """ proxy = make_proxy() Proxy.refresh_features({u'name': proxy['name']})
def test_negative_create_with_url(self): """Proxy creation with random URL :id: 9050b362-c710-43ba-9d77-7680b8f9ed8c :expectedresults: Proxy is not created :CaseImportance: Critical """ # Create a random proxy with self.assertRaisesRegex( CLIFactoryError, u'Could not create the proxy:' ): make_proxy({ u'url': u'http://{0}:{1}'.format( gen_string('alpha', 6), gen_string('numeric', 4)), })
def test_positive_create_with_name(self): """Proxy creation with the home proxy @Feature: Smart Proxy @Assert: Proxy is created """ for name in valid_data_list(): with self.subTest(name): proxy = make_proxy({u'name': name}) self.assertEquals(proxy['name'], name)
def test_positive_remove_capsule(self): """Remove a capsule from location @Assert: Capsule was removed successfully @Feature: Location - Update """ proxy = entities.SmartProxy(id=make_proxy()['id']).search()[0] location = entities.Location(smart_proxy=[proxy]).create() location.smart_proxy = [] location = location.update(['smart_proxy']) self.assertEqual(len(location.smart_proxy), 0)
def test_positive_create_with_capsule(self): """Create new location with assigned capsule to it @Assert: Location created successfully and has correct capsule assigned to it @Feature: Location """ proxy = entities.SmartProxy(id=make_proxy()['id']).search()[0] location = entities.Location(smart_proxy=[proxy]).create() self.assertEqual(location.smart_proxy[0].id, proxy.id) self.assertEqual(location.smart_proxy[0].read().name, proxy.name)
def test_positive_add_capsule_by_name(self): """@Test: Add a capsule by its name @Feature: Organization @Assert: Capsule is added to the org """ org = make_org() proxy = make_proxy() Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], })
def test_positive_create_with_name(self): """Proxy creation with the home proxy @id: 7decd7a3-2d35-43ff-9a20-de44e83c7389 @Assert: Proxy is created """ for name in valid_data_list(): with self.subTest(name): proxy = make_proxy({u'name': name}) self.assertEquals(proxy['name'], name) # Add capsule id to cleanup list self.addCleanup(capsule_cleanup, proxy['id'])
def test_positive_delete_by_id(self): """Proxy deletion with the home proxy @id: 1b6973b1-259d-4866-b36f-c2d5fb154035 @Assert: Proxy is deleted """ for name in valid_data_list(): with self.subTest(name): proxy = make_proxy({u'name': name}) Proxy.delete({'id': proxy['id']}) with self.assertRaises(CLIReturnCodeError): Proxy.info({u'id': proxy['id']})
def test_positive_delete_by_id(self): """Proxy deletion with the home proxy @Feature: Smart Proxy @Assert: Proxy is deleted """ for name in valid_data_list(): with self.subTest(name): proxy = make_proxy({u'name': name}) Proxy.delete({u'id': proxy['id']}) with self.assertRaises(CLIReturnCodeError): Proxy.info({u'id': proxy['id']})
def test_proxy_delete(self, data): """@Test: Proxy deletion with the home proxy @Feature: Smart Proxy @Assert: Proxy is deleted """ try: proxy = make_proxy({u'name': data['name']}) except CLIFactoryError as err: self.fail(err) self.assertEquals( proxy['name'], data['name'], "Input and output name should be consistent") result = Proxy.info({u'id': proxy['id']}) self.assertEqual( result.return_code, 0, "Proxy should be found" ) self.assertEqual( len(result.stderr), 0, "No error excepted" ) result = Proxy.delete({u'id': proxy['id']}) self.assertEqual( result.return_code, 0, "Proxy should be deleted" ) self.assertEqual( len(result.stderr), 0, "No error excepted" ) result = Proxy.info({u'id': proxy['id']}) self.assertNotEqual( result.return_code, 0, "Proxy should not be found" ) self.assertGreater( len(result.stderr), 0, "Expected an error here" )
def test_positive_import_puppet_classes(self): """Import puppet classes from proxy @id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04 @Assert: Puppet classes are imported from proxy """ port = get_available_capsule_port() with default_url_on_new_port(9090, port): url = u'https://{0}:{1}'.format(settings.server.hostname, port) proxy = make_proxy({u'url': url}) Proxy.importclasses({u'id': proxy['id']}) # Add capsule id to cleanup list self.addCleanup(capsule_cleanup, proxy['id'])
def test_proxy_refresh_features_by_name(self): """@Test: Refresh smart proxy features, search for proxy by name @Feature: Smart Proxy @Assert: Proxy features are refreshed """ try: proxy = make_proxy() except CLIFactoryError as err: self.fail(err) result = Proxy.refresh_features({u'name': proxy['name']}) self.assertEqual(result.return_code, 0)
def test_proxy_create(self, data): """ @Test: Proxy creation with the home proxy @Feature: Smart Proxy @Assert: Proxy is created """ try: proxy = make_proxy({'name': data['name']}) except CLIFactoryError as err: self.fail(err) self.assertEquals( proxy['name'], data['name'], "Input and output name should be consistent")
def test_positive_add_capsule_by_id(self): """Add a capsule to organization by its ID @feature: Organization @assert: Capsule is added to the org """ loc = make_location() proxy = make_proxy() Location.add_smart_proxy({ 'name': loc['name'], 'smart-proxy-id': proxy['id'], }) loc = Location.info({'name': loc['name']}) self.assertIn(proxy['name'], loc['smart-proxies'])
def test_proxy_create(self, data): """@Test: Proxy creation with the home proxy @Feature: Smart Proxy @Assert: Proxy is created """ try: proxy = make_proxy({u'name': data['name']}) except CLIFactoryError as err: self.fail(err) self.assertEquals(proxy['name'], data['name'], "Input and output name should be consistent")
def test_positive_add_capsule_by_name(self): """Add a capsule to organization by its name @Feature: Organization @Assert: Capsule is added to the org """ org = make_org() proxy = make_proxy() Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org['smart-proxies'])
def test_positive_add_capsule_by_id(self): """Add a capsule to organization by its ID @feature: Organization @assert: Capsule is added to the org """ org = make_org() proxy = make_proxy() Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy-id': proxy['id'], }) org = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org['smart-proxies'])
def test_positive_create_with_name(self): """Proxy creation with the home proxy :id: 7decd7a3-2d35-43ff-9a20-de44e83c7389 :expectedresults: Proxy is created :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): proxy = make_proxy({u'name': name}) self.assertEquals(proxy['name'], name) # Add capsule id to cleanup list self.addCleanup(capsule_cleanup, proxy['id'])
def test_positive_delete_by_id(self): """Proxy deletion with the home proxy :id: 1b6973b1-259d-4866-b36f-c2d5fb154035 :expectedresults: Proxy is deleted :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): proxy = make_proxy({u'name': name}) Proxy.delete({'id': proxy['id']}) with self.assertRaises(CLIReturnCodeError): Proxy.info({u'id': proxy['id']})
def test_positive_refresh_features_by_id(self): """Refresh smart proxy features, search for proxy by id @Feature: Smart Proxy @Assert: Proxy features are refreshed """ proxy = make_proxy() # parse the port number so we can reopen the SSH tunnel port_regexp = re.search(u':([0-9]+)', proxy['url']) if port_regexp: port = port_regexp.group(1) with default_url_on_new_port(9090, port): Proxy.refresh_features({u'id': proxy['id']}) else: raise ValueError('Unable to parse port number from proxy URL')
def test_positive_import_puppet_classes(session_puppet_enabled_sat, puppet_proxy_port_range): """Import puppet classes from proxy :id: 42e3a9c0-62e1-4049-9667-f3c0cdfe0b04 :expectedresults: Puppet classes are imported from proxy :CaseLevel: Component """ with session_puppet_enabled_sat: port = get_available_capsule_port() with default_url_on_new_port(9090, port) as url: proxy = make_proxy({'url': url}) Proxy.import_classes({'id': proxy['id']}) Proxy.delete({'id': proxy['id']})
def test_positive_delete_by_id(name): """Proxy deletion with the home proxy :id: 1b6973b1-259d-4866-b36f-c2d5fb154035 :expectedresults: Proxy is deleted :CaseLevel: Component :Parametrized: Yes :BZ: 1398695 """ proxy = make_proxy({'name': name}) Proxy.delete({'id': proxy['id']}) with pytest.raises(CLIReturnCodeError): Proxy.info({'id': proxy['id']})
def test_positive_update_hostgroup(request, module_org, env, cv, content_source, puppet_classes): """Update hostgroup's content source, name and puppet classes :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source, name and puppet classes :CaseLevel: Integration """ hostgroup = make_hostgroup( { 'content-source-id': content_source['id'], 'organization-ids': module_org.id, 'environment-id': env['id'], 'content-view-id': cv['id'], 'query-organization-id': module_org.id, } ) new_content_source = make_proxy() @request.addfinalizer def _cleanup(): HostGroup.delete({'id': hostgroup['id']}) capsule_cleanup(new_content_source['id']) assert len(hostgroup['puppetclasses']) == 0 new_name = valid_hostgroups_list()[0] puppet_class_names = [puppet['name'] for puppet in puppet_classes] HostGroup.update( { 'new-name': new_name, 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], 'puppet-classes': puppet_class_names, } ) hostgroup = HostGroup.info({'id': hostgroup['id']}) assert hostgroup['name'] == new_name assert hostgroup['content-source']['name'] == new_content_source['name'] assert set(puppet_class_names) == set(hostgroup['puppetclasses'])
def test_positive_remove_capsule_by_name(self): """Remove a capsule from organization by its name @Feature: Organization @Assert: Capsule is removed from the org """ loc = make_location() proxy = make_proxy() Location.add_smart_proxy({ 'name': loc['name'], 'smart-proxy': proxy['name'], }) Location.remove_smart_proxy({ 'name': loc['name'], 'smart-proxy': proxy['name'], }) loc = Location.info({'name': loc['name']}) self.assertNotIn(proxy['name'], loc['smart-proxies'])
def test_positive_update_hostgroup(self): """Update hostgroup's content source, name and puppet classes :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source, name and puppet classes :CaseLevel: Integration """ hostgroup = make_hostgroup({ 'content-source-id': self.content_source['id'], 'organization-ids': self.org['id'], 'environment-id': self.env['id'], 'content-view-id': self.cv['id'], 'query-organization-id': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) self.assertEqual(len(hostgroup['puppetclasses']), 0) new_name = valid_hostgroups_list()[0] puppet_classes = [puppet['name'] for puppet in self.puppet_classes] HostGroup.update({ 'new-name': new_name, 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], 'puppet-classes': puppet_classes, }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['name'], new_name) self.assertEqual(hostgroup['content-source']['name'], new_content_source['name']) self.assertEqual(set(puppet_classes), set(hostgroup['puppetclasses']))
def test_positive_remove_capsule_by_name(self): """Remove a capsule from organization by its name @Feature: Organization @Assert: Capsule is removed from the org """ org = make_org() proxy = make_proxy() Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) Org.remove_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org = Org.info({'name': org['name']}) self.assertNotIn(proxy['name'], org['smart-proxies'])
def test_positive_update_name(self): """Proxy name update with the home proxy @Feature: Smart Proxy @Assert: Proxy has the name updated """ proxy = make_proxy({u'name': gen_alphanumeric()}) newport = random.randint(9091, 49090) for new_name in valid_data_list(): with self.subTest(new_name): with default_url_on_new_port(9090, newport) as url: Proxy.update({ u'id': proxy['id'], u'name': new_name, u'url': url, }) proxy = Proxy.info({u'id': proxy['id']}) self.assertEqual(proxy['name'], new_name)
def test_positive_add_capsule_by_name(self): """Add a capsule to organization by its name @id: dbf9dd74-3b9e-4124-9468-b0eb978897df @Assert: Capsule is added to the org @CaseLevel: Integration """ org = make_org() proxy = make_proxy() # Add capsule and org to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy': proxy['name'], }) org = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org['smart-proxies'])
def test_positive_update_name(self): """Proxy name update with the home proxy @id: 1a02a06b-e9ab-4b9b-bcb0-ac7060188316 @Assert: Proxy has the name updated """ proxy = make_proxy({u'name': gen_alphanumeric()}) for new_name in valid_data_list(): with self.subTest(new_name): newport = get_available_capsule_port() with default_url_on_new_port(9090, newport) as url: Proxy.update({ u'id': proxy['id'], u'name': new_name, u'url': url, }) proxy = Proxy.info({u'id': proxy['id']}) self.assertEqual(proxy['name'], new_name) # Add capsule id to cleanup list self.addCleanup(capsule_cleanup, proxy['id'])
def test_positive_refresh_features_by_id(self): """Refresh smart proxy features, search for proxy by id :id: d3db63ce-b877-40eb-a863-294c12489ddd :expectedresults: Proxy features are refreshed :CaseLevel: Integration """ # Since we want to run multiple commands against our fake capsule, we # need the tunnel kept open in order not to allow different concurrent # test to claim it. Thus we want to manage the tunnel manually. # get an available port for our fake capsule port = get_available_capsule_port() with default_url_on_new_port(9090, port): url = u'https://{0}:{1}'.format(settings.server.hostname, port) proxy = make_proxy({u'url': url}) Proxy.refresh_features({u'id': proxy['id']}) # Add capsule id to cleanup list self.addCleanup(capsule_cleanup, proxy['id'])
def test_positive_remove_capsule(self): """Remove a capsule from location @id: 43221ef8-054b-4311-8be0-e02f32e30d98 @Assert: Capsule was removed successfully @CaseLevel: Integration """ proxy_id = make_proxy()['id'] # Add capsule to cleanup list self.addCleanup(capsule_cleanup, proxy_id) proxy = entities.SmartProxy(id=proxy_id).search()[0] location = entities.Location(smart_proxy=[proxy]).create() # Add location to cleanup list self.addCleanup(location_cleanup, location.id) location.smart_proxy = [] location = location.update(['smart_proxy']) self.assertEqual(len(location.smart_proxy), 0)
def test_positive_create_with_capsule(self): """Create new location with assigned capsule to it @id: 73f07e4b-b180-4906-8189-e9c0345abc5c @Assert: Location created successfully and has correct capsule assigned to it @CaseLevel: Integration """ proxy_id = make_proxy()['id'] # Add capsule to cleanup list self.addCleanup(capsule_cleanup, proxy_id) proxy = entities.SmartProxy(id=proxy_id).search()[0] location = entities.Location(smart_proxy=[proxy]).create() # Add location to cleanup list self.addCleanup(location_cleanup, location.id) self.assertEqual(location.smart_proxy[0].id, proxy.id) self.assertEqual(location.smart_proxy[0].read().name, proxy.name)
def test_positive_refresh_features_by_name(self): """Refresh smart proxy features, search for proxy by name @id: 2ddd0097-8f65-430e-963d-a3b5dcffe86b @Assert: Proxy features are refreshed @CaseLevel: Integration """ # Since we want to run multiple commands against our fake capsule, we # need the tunnel kept open in order not to allow different concurrent # test to claim it. Thus we want to manage the tunnel manually. # get an available port for our fake capsule port = get_available_capsule_port() with default_url_on_new_port(9090, port): url = u'https://{0}:{1}'.format(settings.server.hostname, port) proxy = make_proxy({u'url': url}) Proxy.refresh_features({u'id': proxy['name']}) # Add capsule id to cleanup list self.addCleanup(capsule_cleanup, proxy['id'])
def test_positive_add_capsule_by_id(self): """Add a capsule to location by its ID :id: 15e3c1e6-4fa3-4965-8808-a9ba01d1c050 :expectedresults: Capsule is added to the org :CaseLevel: Integration """ loc = make_location() proxy = make_proxy() # Add capsule and location to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(location_cleanup, loc['id']) Location.add_smart_proxy({ 'name': loc['name'], 'smart-proxy-id': proxy['id'], }) loc = Location.info({'name': loc['name']}) self.assertIn(proxy['name'], loc['smart-proxies'])
def test_positive_add_capsule_by_id(self): """Add a capsule to organization by its ID @id: 0a64ebbe-d357-4ca8-b19e-86ea0963dc71 @assert: Capsule is added to the org @CaseLevel: Integration """ org = make_org() proxy = make_proxy() # Add capsule and org to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(org_cleanup, org['id']) Org.add_smart_proxy({ 'name': org['name'], 'smart-proxy-id': proxy['id'], }) org = Org.info({'name': org['name']}) self.assertIn(proxy['name'], org['smart-proxies'])
def test_positive_add_capsule_by_name(self): """Add a capsule to location by its name :id: 32b1e969-a1a8-4d65-bde9-a825ab542b1d :expectedresults: Capsule is added to the org :CaseLevel: Integration """ loc = make_location() proxy = make_proxy() # Add capsule and location to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) self.addCleanup(location_cleanup, loc['id']) Location.add_smart_proxy({ 'name': loc['name'], 'smart-proxy': proxy['name'], }) loc = Location.info({'name': loc['name']}) self.assertIn(proxy['name'], loc['smart-proxies'])
def proxy(): """Create a Proxy and clean up when done.""" proxy = make_proxy() yield proxy capsule_cleanup(proxy_id=proxy['id'])
def _make_proxy(options=None): """Create a Proxy and register the cleanup function""" proxy = make_proxy(options=options) yield proxy capsule_cleanup(proxy['id'])
def _make_proxy(request): """Create a Proxy and register the cleanup function""" proxy = make_proxy() request.addfinalizer(lambda: capsule_cleanup(proxy['id'])) return proxy
def _make_proxy(self, options=None): """Create a Proxy and register the cleanup function""" proxy = make_proxy(options=options) # Add capsule to cleanup list self.addCleanup(capsule_cleanup, proxy['id']) return proxy