예제 #1
0
    def test_update_user_skill_ok_response(
        self,
        mock_user_skill_repo_get,
        mock_user_skill_controller_request_params,
        mock_user_skill_repo_find_first,
    ):
        """Test update_user_skill when role doesn't exist."""
        # Arrange
        with self.app.app_context():
            mock_user_skill_repo_get.return_value = self.mock_user_skill
            mock_user_skill_repo_find_first.return_value = self.mock_user_skill
            mock_user_skill_controller_request_params.return_value = (
                self.user.id,
                self.mock_user_skill.id,
                "expert",
                5,
                self.skill_one.id,
            )
            user_skill_controller = UserSkillController(self.request_context)

            # Act
            result = user_skill_controller.update_user_skill(
                self.mock_user_skill.id)
            print(result)
            # Assert
            assert result.status_code == 200
            assert result.get_json()["msg"] == "OK"
            assert (result.get_json()["payload"]["user_skill"]["skill_id"] ==
                    self.skill_one.id)
예제 #2
0
    def test_update_user_skill_when_user_skill_doesnot_exist(
        self,
        mock_user_skill_repo_get,
        mock_user_skill_controller_request_params,
    ):
        """Test update_user_skill when role doesn't exist."""
        # Arrange
        with self.app.app_context():
            mock_user_skill_repo_get.return_value = None
            mock_user_skill_controller_request_params.return_value = (
                None,
                None,
                None,
                None,
                None,
            )
            user_skill_controller = UserSkillController(self.request_context)

            # Act
            result = user_skill_controller.update_user_skill(1)

            # Assert
            assert result.status_code == 400
            assert (result.get_json()["msg"] == "Invalid or incorrect "
                    "user_skill_id provided")