def find_user(self, dbo):
        """test find user, CRUD method

        :param dbObject dbo: dbo
        """
        self.reset(dbo)

        # 1. find user from db
        with orm.db_session:
            temp_user, _ = User.find_user_by_id(self.user.id)

            # 2. test value
            self.assert_value(temp_user)

            temp_user, err = User.find_user_by_id(-1)

            # 3. assert on error
            self.assertEqual(err, "User Not Found !")
            self.assertEqual(temp_user, None)

            # 4. find_all user from db
            temp_users = User.find_all_users()

            # 5. test value
            self.assertEqual(len(temp_users), 1)
            self.assert_value(temp_users[0])
示例#2
0
def seed_project():
    _project = Project.create_project("sample_project", "SP", 2020, 2021)

    # get user and link it to project
    _user = User.find_all_users()[0]

    _project.users += _user
    return _project