Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/unit/app/endpoints/test_feedback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Unit tests for the /feedback REST API endpoint."""

from unittest.mock import patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use pytest


from fastapi import HTTPException, status
import pytest

Expand All @@ -15,14 +17,20 @@

def test_is_feedback_enabled():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def test_is_feedback_enabled(mocker):
...
    with mocker.patch(....

"""Test that is_feedback_enabled returns True when feedback is not disabled."""
configuration.user_data_collection_configuration.feedback_enabled = True
assert is_feedback_enabled() is True, "Feedback should be enabled"
with patch(
"app.endpoints.feedback.configuration.user_data_collection_configuration.feedback_enabled",
True,
):
assert is_feedback_enabled() is True, "Feedback should be enabled"


def test_is_feedback_disabled():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, let's use mocker instead of built-in mock since we already use pytest

"""Test that is_feedback_enabled returns False when feedback is disabled."""
configuration.user_data_collection_configuration.feedback_enabled = False
assert is_feedback_enabled() is False, "Feedback should be disabled"
with patch(
"app.endpoints.feedback.configuration.user_data_collection_configuration.feedback_enabled",
False,
):
assert is_feedback_enabled() is False, "Feedback should be disabled"


async def test_assert_feedback_enabled_disabled(mocker):
Expand Down
Loading