def factory_user_model_with_contact(user_info: dict = TestUserInfo.user1, keycloak_guid=None): """Produce a user model.""" user_type = Role.ANONYMOUS_USER.name if user_info.get( 'access_type', None) == AccessType.ANONYMOUS.value else None user = UserModel(username=user_info.get( 'username', user_info.get('preferred_username')), firstname=user_info['firstname'], lastname=user_info['lastname'], keycloak_guid=user_info.get('keycloak_guid', keycloak_guid), type=user_type, email='*****@*****.**', login_source=user_info.get('loginSource')) user.save() contact = factory_contact_model() contact.save() contact_link = ContactLinkModel() contact_link.contact = contact contact_link.user = user contact_link.save() return user
def factory_user_model_with_contact(): """Produce a user model.""" user_info = { 'username': '******', 'firstname': 'bar', 'lastname': 'User', 'keycloak_guid': uuid.uuid4() } user = UserModel( username=user_info['username'], firstname=user_info['firstname'], lastname=user_info['lastname'], keycloak_guid=user_info.get('keycloak_guid', None), type=user_info.get('access_type', None), ) user.save() contact = factory_contact_model() contact.save() contact_link = ContactLinkModel() contact_link.contact = contact contact_link.user = user contact_link.save() return user
def factory_user_model(): """Produce a user model.""" user = User(username='******', roles='{edit, uma_authorization, staff}', keycloak_guid=uuid.uuid4()) user.save() return user
def factory_user_model(user_info: dict = TestUserInfo.user1): """Produce a user model.""" user = UserModel(username=user_info['username'], firstname=user_info['firstname'], lastname=user_info['lastname'], roles=user_info['roles'], keycloak_guid=user_info['keycloak_guid']) user.save() return user
def factory_user_model(user_info: dict = TestUserInfo.user1): """Produce a user model.""" user = UserModel(username=user_info['username'], firstname=user_info['firstname'], lastname=user_info['lastname'], roles=user_info['roles'], keycloak_guid=user_info.get('keycloak_guid', None), type=user_info.get('access_type', None), email='*****@*****.**', login_source=user_info.get('login_source', None), ) user.save() return user
def factory_user_model(user_info: dict = TestUserInfo.user1): """Produce a user model.""" user_type = Role.ANONYMOUS_USER.name if user_info.get('access_type', None) == AccessType.ANONYMOUS.value else None user = UserModel(username=user_info['username'], firstname=user_info['firstname'], lastname=user_info['lastname'], keycloak_guid=user_info.get('keycloak_guid', None), type=user_type, email='*****@*****.**', login_source=user_info.get('login_source', None), ) user.save() return user
def factory_user_model_with_contact(user_info: dict = TestUserInfo.user1): """Produce a user model.""" user = UserModel(username=user_info['username'], firstname=user_info['firstname'], lastname=user_info['lastname'], roles=user_info['roles'], keycloak_guid=user_info.get('keycloak_guid', None), type=user_info.get('access_type', None), email='*****@*****.**') user.save() contact = factory_contact_model() contact.save() contact_link = ContactLinkModel() contact_link.contact = contact contact_link.user = user contact_link.save() return user