def test_validate_lock_params_invalid(self):
     invalid = [{
         'test': 'just name and type',
         'name': 'foo',
         'resource_type': 'baz'
     }, {
         'test': 'name and group and type',
         'name': 'foo',
         'resource_group_name': 'foo',
         'resource_type': 'bar',
     }, {
         'test': 'name, group, no type',
         'name': 'foo',
         'resource_group_name': 'bar',
         'resource_name': 'baz',
     }, {
         'test': 'name, group, type, namespace',
         'name': 'foo',
         'resource_group_name': 'bar',
         'resource_name': 'baz',
         'resource_provider_namespace': 'Microsoft.Compute',
     }, {
         'test': 'name, group, type, namespace, parent',
         'name': 'foo',
         'resource_group_name': 'bar',
         'resource_type': 'VirtualMachines',
         'resource_provider_namespace': 'Microsoft.Compute',
         'parent_resource_path': 'Foo.Bar/baz',
     }]
     for invalid_namespace in invalid:
         with self.assertRaises(CLIError):
             namespace_obj = NamespaceObject()
             for key in invalid_namespace:
                 setattr(namespace_obj, key, invalid_namespace[key])
             validate_lock_parameters(namespace_obj)
 def test_validate_lock_params(self):
     valid = [
         {
             'test': 'just name',
             'name': 'foo'
         },
         {
             'test': 'name and group',
             'name': 'foo',
             'resource_group': 'foo',
         },
         {
             'test': 'name, group, type [compact]',
             'name': 'foo',
             'resource_group': 'bar',
             'resource_name': 'baz',
             'resource_type': 'Microsoft.Compute/VirtualMachines'
         },
         {
             'test': 'name, group, type, namespace',
             'name': 'foo',
             'resource_group': 'bar',
             'resource_name': 'baz',
             'resource_type': 'VirtualMachines',
             'resource_provider_namespace': 'Microsoft.Compute',
         },
         {
             'test': 'name, group, type, namespace, parent',
             'name': 'foo',
             'resource_group': 'bar',
             'resource_name': 'baz',
             'resource_type': 'VirtualMachines',
             'resource_provider_namespace': 'Microsoft.Compute',
             'parent_resource_path': 'Foo.Bar/baz',
         }
     ]
     for valid_namespace in valid:
         namespace_obj = NamespaceObject()
         for key in valid_namespace:
             setattr(namespace_obj, key, valid_namespace[key])
         try:
             # If unexpected invalid, this throws, so no need for asserts
             validate_lock_parameters(namespace_obj)
         except CLIError as ex:
             self.fail('Test {} failed. {}'.format(valid_namespace['test'], ex))
 def test_validate_lock_params_invalid(self):
     invalid = [
         {
             'test': 'just name and type',
             'name': 'foo',
             'resource_type': 'baz'
         },
         {
             'test': 'name and group and type',
             'name': 'foo',
             'resource_group': 'foo',
             'resource_type': 'bar',
         },
         {
             'test': 'name, group, no type',
             'name': 'foo',
             'resource_group': 'bar',
             'resource_name': 'baz',
         },
         {
             'test': 'name, group, type, namespace',
             'name': 'foo',
             'resource_group': 'bar',
             'resource_name': 'baz',
             'resource_provider_namespace': 'Microsoft.Compute',
         },
         {
             'test': 'name, group, type, namespace, parent',
             'name': 'foo',
             'resource_group': 'bar',
             'resource_type': 'VirtualMachines',
             'resource_provider_namespace': 'Microsoft.Compute',
             'parent_resource_path': 'Foo.Bar/baz',
         }
     ]
     for invalid_namespace in invalid:
         with self.assertRaises(CLIError):
             namespace_obj = NamespaceObject()
             for key in invalid_namespace:
                 setattr(namespace_obj, key, invalid_namespace[key])
             validate_lock_parameters(namespace_obj)