コード例 #1
0
    def test_userprofile_is_saved_in_db(self):
        """Test if the user profile has been successfully saved in the database
        after creating a new user"""
        user = UserModel(username="******", password="******")
        user.save_to_db()
        userprofile = UserProfileModel(user_id=user.id)
        userprofile.save_to_db()
        found_userprofile = UserProfileModel.find_by_username(user.username)

        self.assertIsNotNone(found_userprofile)
コード例 #2
0
    def test_find_by_username_no_user(self):
        """Test if None is returned
        if the user with the given username doesn't exist"""
        found_userprofile = UserProfileModel.find_by_username("test")

        self.assertIsNone(found_userprofile)
コード例 #3
0
    def test_find_by_username(self):
        """Test if the user profile is found"""
        user = self._create_sample_user("test")
        found_userprofile = UserProfileModel.find_by_username("test")

        self.assertEqual(found_userprofile.user_id, user.id)