Example #1
0
def test_cred_type_injectors_schema(injectors, valid):
    type_ = CredentialType(kind='cloud',
                           name='SomeCloud',
                           managed_by_tower=True,
                           inputs={
                               'fields': [
                                   {
                                       'id': 'username',
                                       'type': 'string',
                                       'label': '_'
                                   },
                                   {
                                       'id': 'pass',
                                       'type': 'string',
                                       'label': '_'
                                   },
                                   {
                                       'id': 'awx_secret',
                                       'type': 'string',
                                       'label': '_'
                                   },
                                   {
                                       'id': 'host',
                                       'type': 'string',
                                       'label': '_'
                                   },
                               ]
                           },
                           injectors=injectors)
    if valid is False:
        with pytest.raises(ValidationError):
            type_.full_clean()
    else:
        type_.full_clean()
Example #2
0
def test_cred_type_input_schema_validity(input_, valid):
    type_ = CredentialType(kind='cloud',
                           name='SomeCloud',
                           managed_by_tower=True,
                           inputs=input_)
    if valid is False:
        with pytest.raises(Exception) as e:
            type_.full_clean()
        assert e.type in (ValidationError, serializers.ValidationError)
    else:
        type_.full_clean()