-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
262 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
|
||
from features.feature_health.models import FeatureHealthProvider | ||
from projects.models import Project | ||
from users.models import FFAdminUser | ||
|
||
|
||
@pytest.fixture | ||
def feature_health_provider( | ||
project: Project, | ||
staff_user: FFAdminUser, | ||
) -> FeatureHealthProvider: | ||
return FeatureHealthProvider.objects.create( | ||
created_by=staff_user, | ||
project=project, | ||
name="Sample", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import uuid | ||
|
||
from pytest_mock import MockerFixture | ||
from pytest_structlog import StructuredLogCapture | ||
|
||
from features.feature_health.services import get_provider_response | ||
|
||
|
||
def test_get_provider_response__invalid_provider__return_none__log_expected( | ||
mocker: MockerFixture, | ||
log: "StructuredLogCapture", | ||
) -> None: | ||
# Given | ||
expected_provider_name = "invalid_provider" | ||
expected_provider_uuid = uuid.uuid4() | ||
|
||
invalid_provider_mock = mocker.MagicMock() | ||
invalid_provider_mock.name = expected_provider_name | ||
invalid_provider_mock.uuid = expected_provider_uuid | ||
|
||
# When | ||
response = get_provider_response(invalid_provider_mock, "payload") | ||
|
||
# Then | ||
assert response is None | ||
assert log.events == [ | ||
{ | ||
"event": "invalid-feature-health-provider-requested", | ||
"level": "error", | ||
"provider_id": expected_provider_uuid, | ||
"provider_name": expected_provider_name, | ||
}, | ||
] |