def test_check_with_invalid_values(self): objects.Cluster.update_attributes( self.cluster, self.attributes_data) attributes = objects.Cluster.get_editable_attributes(self.cluster) models = { 'settings': attributes, 'default': attributes, } errs = AttributesRestriction.check_data(models, attributes) self.assertItemsEqual( errs, ['Invalid username', 'Invalid tenant name'])
def test_check_with_valid_values(self): access = self.attributes_data["editable"]["access"] access["user"]["value"] = "admin" access["tenant"]["value"] = ["test"] access["another_tenant"]["value"] = ["test1", "test2"] access["another_tenant_2"]["value"] = ["test1", "test2"] objects.Cluster.update_attributes(self.cluster, self.attributes_data) attributes = objects.Cluster.get_editable_attributes(self.cluster) models = {"settings": attributes, "default": attributes} errs = AttributesRestriction.check_data(models, attributes) self.assertListEqual(errs, [])
def test_check_with_valid_values(self): access = self.attributes_data['editable']['access'] access['user']['value'] = 'admin' access['tenant']['value'] = 'test' objects.Cluster.update_attributes( self.cluster, self.attributes_data) attributes = objects.Cluster.get_editable_attributes(self.cluster) models = { 'settings': attributes, 'default': attributes, } errs = AttributesRestriction.check_data(models, attributes) self.assertListEqual(errs, [])
def test_check_with_invalid_values(self): objects.Cluster.update_attributes(self.cluster, self.attributes_data) attributes = objects.Cluster.get_editable_attributes(self.cluster) models = { 'settings': attributes, 'default': attributes, } errs = AttributesRestriction.check_data(models, attributes) self.assertItemsEqual(errs, [ 'Invalid username', ['Invalid tenant name'], "Value ['test'] should have at least 2 items", "Value ['test1', 'test2', 'test3'] " "should not have more than 2 items" ])
def test_check_with_invalid_values(self): objects.Cluster.update_attributes( self.cluster, self.attributes_data) attributes = objects.Cluster.get_editable_attributes(self.cluster) models = { 'settings': attributes, 'default': attributes, } errs = AttributesRestriction.check_data(models, attributes) self.assertItemsEqual( errs, ['Invalid username', ['Invalid tenant name'], "Value ['test'] should have at least 2 items", "Value ['test1', 'test2', 'test3'] " "should not have more than 2 items"])