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)
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']]
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'
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'
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'
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', )