Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move tests to unit #2987

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
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
Empty file removed api/app/tests/__init__.py
Empty file.
16 changes: 0 additions & 16 deletions api/app/tests/test_urls.py

This file was deleted.

Empty file.
15 changes: 15 additions & 0 deletions api/tests/unit/app/test_unit_app_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APIClient


def test_health_check_endpoint_returns_200(db: None, api_client: APIClient):
# Given
base_url = reverse("health:health_check_home")
url = base_url + "?format=json"

# When
res = api_client.get(url)

# Then
assert res.status_code == status.HTTP_200_OK
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
from projects.models import Project


def test_audit_log_can_be_filtered_by_environments(admin_client, project, environment):
def test_audit_log_can_be_filtered_by_environments(
admin_client: APIClient, project: Project, environment: Environment
) -> None:
# Given
audit_env = Environment.objects.create(name="env_n", project=project)

Expand All @@ -30,7 +32,9 @@ def test_audit_log_can_be_filtered_by_environments(admin_client, project, enviro
assert response.json()["results"][0]["environment"]["id"] == audit_env.id


def test_audit_log_can_be_filtered_by_log_text(admin_client, project, environment):
def test_audit_log_can_be_filtered_by_log_text(
admin_client: APIClient, project: Project, environment: Environment
) -> None:
# Given
flag_state_updated_log = "Flag state updated"
flag_state_deleted_log = "flag state deleted"
Expand All @@ -52,8 +56,11 @@ def test_audit_log_can_be_filtered_by_log_text(admin_client, project, environmen


def test_audit_log_can_be_filtered_by_project(
admin_client, project, environment, organisation
):
admin_client: APIClient,
project: Project,
environment: Environment,
organisation: Organisation,
) -> None:
# Given
another_project = Project.objects.create(
name="another_project", organisation=organisation
Expand All @@ -75,8 +82,11 @@ def test_audit_log_can_be_filtered_by_project(


def test_audit_log_can_be_filtered_by_is_system_event(
admin_client, project, environment, organisation
):
admin_client: APIClient,
project: Project,
environment: Environment,
organisation: Organisation,
) -> None:
# Given
AuditLog.objects.create(project=project, is_system_event=True)
AuditLog.objects.create(
Expand All @@ -100,7 +110,7 @@ def test_regular_user_cannot_list_audit_log(
organisation: Organisation,
django_user_model: typing.Type[Model],
api_client: APIClient,
):
) -> None:
# Given
AuditLog.objects.create(environment=environment)
url = reverse("api-v1:audit-list")
Expand All @@ -120,7 +130,7 @@ def test_admin_user_cannot_list_audit_log_of_another_organisation(
organisation: Organisation,
project: Project,
django_user_model: typing.Type[Model],
):
) -> None:
# Given
another_organisation = Organisation.objects.create(name="another organisation")
user = django_user_model.objects.create(email="[email protected]")
Expand Down