Skip to content

Commit

Permalink
fix: Move tests to unit (#2987)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed Nov 16, 2023
1 parent 627a6fa commit 43caad8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 24 deletions.
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
File renamed without changes.
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="test@example.com")
Expand Down

3 comments on commit 43caad8

@vercel
Copy link

@vercel vercel bot commented on 43caad8 Nov 16, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 43caad8 Nov 16, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 43caad8 Nov 16, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

docs – ./docs

docs.flagsmith.com
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs-flagsmith.vercel.app

Please sign in to comment.