def test_vsphere_no_validation(self): cloud = { 'type': 'vsphere', 'endpoint': '1.2.3.4', 'regions': { 'q': { 'endpoint': '1.2.3.4' } }, } spec = cloud_spec('foo', 'foo', cloud, exception=None) self.assertItemsEqual([ self.bogus_type, spec, xfail( cloud_spec('invalid-name-foo', 'invalid/name', cloud, exception=NameNotAccepted), 1641981, None), xfail( cloud_spec('long-name-foo', long_text, cloud, exception=None), 1641970, NameMismatch), xfail(make_long_endpoint(spec, endpoint_validation, regions=True), 1641970, CloudMismatch), ], iter_clouds({'foo': cloud}, basic_validation))
def test_manual(self): self.maxDiff = None cloud = {'type': 'manual', 'endpoint': 'http://example.com'} spec = cloud_spec('foo', 'foo', cloud) self.assertItemsEqual([ self.bogus_type, spec, xfail(cloud_spec('long-name-foo', long_text, cloud), 1641970, NameMismatch), xfail(cloud_spec('invalid-name-foo', 'invalid/name', cloud, exception=NameNotAccepted), 1641981, None), make_long_endpoint(spec, basic_validation) ], iter_clouds({'foo': cloud}, endpoint_validation))
def test_manual_no_validation(self): self.maxDiff = None cloud = {'type': 'manual', 'endpoint': 'http://example.com'} spec = cloud_spec('foo', 'foo', cloud) self.assertItemsEqual([ self.bogus_type, spec, xfail(cloud_spec('long-name-foo', long_text, cloud), 1641970, NameMismatch), xfail( cloud_spec('invalid-name-foo', 'invalid/name', cloud, exception=NameNotAccepted), 1641981, None), make_long_endpoint(spec, basic_validation) ], iter_clouds({'foo': cloud}, basic_validation))
def test_vsphere(self): cloud = { 'type': 'vsphere', 'endpoint': '1.2.3.4', 'regions': {'q': {'endpoint': '1.2.3.4'}}, } spec = cloud_spec('foo', 'foo', cloud, exception=None) self.assertItemsEqual([ self.bogus_type, spec, xfail(cloud_spec('invalid-name-foo', 'invalid/name', cloud, exception=NameNotAccepted), 1641981, None), xfail(cloud_spec('long-name-foo', long_text, cloud, exception=None), 1641970, NameMismatch), make_long_endpoint( spec, endpoint_validation, regions=True), ], iter_clouds({'foo': cloud}, endpoint_validation))
def make_long_endpoint(spec, validation, regions=False): config = deepcopy(spec.config) config['endpoint'] = long_text if regions: for region in config['regions'].values(): region['endpoint'] = long_text spec = cloud_spec('long-endpoint-{}'.format(spec.name), spec.name, config, InvalidEndpoint) if validation.is_basic: spec = xfail(spec, 1641970, CloudMismatch) return spec
def make_long_endpoint(spec, validation, regions=False): config = deepcopy(spec.config) config['endpoint'] = long_text if regions: for region in config['regions'].values(): region['endpoint'] = long_text spec = cloud_spec('long-endpoint-{}'.format(spec.name), spec.name, config, InvalidEndpoint) if validation.is_basic: spec = xfail(spec, 1641970, CloudMismatch) return spec
def test_openstack(self): config = {'type': 'openstack', 'endpoint': 'http://example.com', 'regions': {'bar': {'endpoint': 'http://baz.example.com'}}} spec = cloud_spec('foo', 'foo', config, exception=None) invalid_name = xfail( cloud_spec('invalid-name-foo', 'invalid/name', config, exception=NameNotAccepted), 1641981, None) long_name = xfail( cloud_spec('long-name-foo', long_text, config, exception=None), 1641970, NameMismatch) long_region = cloud_spec( 'long-endpoint-foo-bar', 'foo', deepcopy(config), InvalidEndpoint) long_region.config['regions']['bar']['endpoint'] = long_text bogus_auth = cloud_spec('bogus-auth-foo', 'foo', deepcopy(config), exception=AuthNotAccepted) bogus_auth.config['auth-types'] = ['asdf'] self.assertItemsEqual([ self.bogus_type, spec, invalid_name, long_name, long_region, bogus_auth, make_long_endpoint(spec, endpoint_validation), ], iter_clouds({'foo': config}, endpoint_validation))
def test_xfail(self): cloud_specs = [xfail(cloud_spec('label1', 'name1', {'config': '1'}), 27, TypeNotAccepted)] client = fake_juju_client(juju_home=self.juju_home) with patch('assess_add_cloud.assess_cloud', side_effect=TypeNotAccepted): with patch('logging.exception') as exception_mock: with patch('sys.stdout'): succeeded, xfailed, failed = assess_all_clouds(client, cloud_specs) self.assertEqual(set(), failed) self.assertEqual({27: {'label1'}}, xfailed) self.assertEqual(0, exception_mock.call_count)
def test_openstack_no_validation(self): config = { 'type': 'openstack', 'endpoint': 'http://example.com', 'regions': { 'bar': { 'endpoint': 'http://baz.example.com' } } } spec = cloud_spec('foo', 'foo', config, exception=None) invalid_name = xfail( cloud_spec('invalid-name-foo', 'invalid/name', config, exception=NameNotAccepted), 1641981, None) long_name = xfail( cloud_spec('long-name-foo', long_text, config, exception=None), 1641970, NameMismatch) long_region = xfail( cloud_spec('long-endpoint-foo-bar', 'foo', deepcopy(config), InvalidEndpoint), 1641970, CloudMismatch) long_region.config['regions']['bar']['endpoint'] = long_text bogus_auth = cloud_spec('bogus-auth-foo', 'foo', deepcopy(config), exception=AuthNotAccepted) bogus_auth.config['auth-types'] = ['asdf'] self.assertItemsEqual([ self.bogus_type, spec, invalid_name, long_name, long_region, bogus_auth, make_long_endpoint(spec, basic_validation), ], iter_clouds({'foo': config}, basic_validation))
def test_xfail(self): cloud_specs = [ xfail(cloud_spec('label1', 'name1', {'config': '1'}), 27, TypeNotAccepted) ] client = fake_juju_client(juju_home=self.juju_home) with patch('assess_add_cloud.assess_cloud', side_effect=TypeNotAccepted): with patch('logging.exception') as exception_mock: with patch('sys.stdout'): succeeded, xfailed, failed = assess_all_clouds( client, cloud_specs) self.assertEqual(set(), failed) self.assertEqual({27: {'label1'}}, xfailed) self.assertEqual(0, exception_mock.call_count)
def test_xfail(self): spec = CloudSpec('label', 'name', {'config': 'value'}, 'foo', 'bar') fail_spec = xfail(spec, 'baz', 'qux') self.assertEqual(fail_spec, CloudSpec( 'label', 'name', {'config': 'value'}, 'qux', 'baz'))
def test_xfail(self): spec = CloudSpec('label', 'name', {'config': 'value'}, 'foo', 'bar') fail_spec = xfail(spec, 'baz', 'qux') self.assertEqual( fail_spec, CloudSpec('label', 'name', {'config': 'value'}, 'qux', 'baz'))