Example #1
0
    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')
Example #2
0
    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')
Example #3
0
    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')
Example #4
0
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())
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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')