def test_init(self): authuser1 = AuthoriseUser(name='user1') self.assertIsNotNone(authuser1) self.assertEqual("<AuthoriseUser(id='n/a', name='user1')>", str(authuser1)) authuser2 = AuthoriseUser(id=1, name='user1') self.assertIsNotNone(authuser2) self.assertEqual("<AuthoriseUser(id='1', name='user1')>", str(authuser2))
def _upload_users(self, yaml_data, verbose=False): if 'users' in yaml_data: for user_name in yaml_data['users'].keys(): auth_user = AuthoriseUser(name=user_name) result = self.storage_engine.session.add(auth_user) yaml_obj = yaml_data['users'][user_name] if 'roles' in yaml_obj: roles_list = yaml_obj['roles'] splits = roles_list.split(",") for role_name in splits: role_name = role_name.strip() user_role = UserRole(user=user_name, role=role_name) if verbose is True: outputLog(self, user_role) self.storage_engine.session.add(user_role) if 'groups' in yaml_obj: groups_list = yaml_obj['groups'] splits = groups_list.split(",") for group_name in splits: group_name = group_name.strip() user_group = UserGroup(user=user_name, group=group_name) if verbose is True: outputLog(self, user_group) self.storage_engine.session.add(user_group)