def test_none_validation(self): choice = ChoiceField(choices=[ ('DESCRIPTION', 'value'), ('DESCRIPTION 2', 'value2'), ], null=False) had_exception = False try: choice.validate() except: had_exception = True self.assertTrue(had_exception, 'The value cannot be None')
def test_none_validation(self): choice = ChoiceField(choices=[ ('value', 'DESCRIPTION'), ('value2', 'DESCRIPTION 2'), ], null=False) had_exception = False try: choice.validate() except: had_exception = True self.assertTrue(had_exception, 'The value cannot be None')
def test_field_validation(self): choice = ChoiceField(choices=[ ('DESCRIPTION', 'value'), ('DESCRIPTION 2', 'value2'), ]) had_exception = False try: choice.set('not_valid_value') except Exception as err: had_exception = True self.assertTrue(had_exception, 'The value is not valid') choice.set('value2') self.assertTrue(True, 'The value is valid')
class ScheduleIntervalSettings(CollectionModel): account_id = ForeignKeyField(to=AwsCredentials, required=True) service = ChoiceField(choices=[('assets', 'For assets'), ('iam', 'For iam policy'), ('lambda', 'For Lambda functions'), ('rds', 'For rds'), ('s3', 'For s3 bucket'), ('cloud-trail', 'For cloud trail'), ('cloud-watch', 'For cloud watch'), ('vpc', 'For VPC'), ('all', 'For all aws services')], required=True) repeat_delay = NumberField(required=True) user = NumberField(required=True) created_on = DatetimeField(default=datetime.datetime.now())
def test_equals(self): choice1 = ChoiceField(choices=[ ('value', 'DESCRIPTION'), ('value2', 'DESCRIPTION 2'), ]) choice1.set('value') choice2 = ChoiceField(choices=[ ('value', 'DESCRIPTION'), ('value2', 'DESCRIPTION 2'), ]) choice2.set('value') self.assertEqual(choice1, choice2)
def test_equals(self): choice1 = ChoiceField(choices=[ ('DESCRIPTION', 'value'), ('DESCRIPTION 2', 'value2'), ]) choice1.set('value') choice2 = ChoiceField(choices=[ ('DESCRIPTION', 'value'), ('DESCRIPTION 2', 'value2'), ]) choice2.set('value') self.assertEqual(choice1, choice2)
def test_field_validation(self): choice = ChoiceField(choices=[ ('value', 'DESCRIPTION'), ('value2', 'DESCRIPTION 2'), ]) had_exception = False try: choice.set('not_valid_value') except Exception as err: had_exception = True self.assertTrue(had_exception, 'The value is not valid') choice.set('value2') self.assertTrue(True, 'The value is valid')