Example #1
0
def test_adding_two_properties_with_same_name_raises_error():

    property_manager = UserPropertyManager(
        groups=[
            {
                'name': 'your_org',
                'displayName': 'Your API Data'
            }
        ]
    )

    property_manager.add_prop(
        BaseUserProperty(
            name='some_org_is_active',
            label='Active Account User',
            group_name='some_org',
            native_type='bool',
        )
    )

    with pytest.raises(ValueError) as err:

        property_manager.add_prop(
            BaseUserProperty(
                name='some_org_is_active',
                label='Active Account User',
                group_name='some_org',
                native_type='bool',
            )
        )

        assert 'Manager already contains' in str(err.value)
Example #2
0
def test_bool_native_type_to_hs_type_get_dict():
    active_user = BaseUserProperty(
        name='some_org_is_active',
        label='Active Account User',
        group_name='some_org',
        native_type='bool',
    )

    _dict = active_user.get_dict()

    assert 'Yes' in [o['label'] for o in _dict['options']]
Example #3
0
def test_texarea_native_type_to_hs_type():
    active_user = BaseUserProperty(
        name='some_org_is_active',
        label='Active Account User',
        group_name='some_org',
        native_type='textarea',
    )

    assert active_user.hs_type == 'string'
    assert active_user.field_type == 'textarea'
Example #4
0
def test_datetime_native_type_to_hs_type():
    active_user = BaseUserProperty(
        name='some_org_is_active',
        label='Active Account User',
        group_name='some_org',
        native_type='datetime',
    )

    assert active_user.hs_type == 'datetime'
    assert active_user.field_type == 'date'
Example #5
0
def test_bool_native_type_to_hs_type():
    active_user = BaseUserProperty(
        name='some_org_is_active',
        label='Active Account User',
        group_name='some_org',
        native_type='bool',
    )

    assert active_user.hs_type == 'enumeration'
    assert active_user.field_type == 'booleancheckbox'
Example #6
0
def test_cannot_use_type_other_than_those_listed():

    with pytest.raises(KeyError):

        BaseUserProperty(
            name='some_org_is_active',
            label='Active Account User',
            group_name='some_org',
            native_type='numberolog',
        )