|
6 | 6 | from django.urls import reverse
|
7 | 7 | from django.utils import timezone
|
8 | 8 | from pytest_lazyfixture import lazy_fixture
|
| 9 | +from pytest_mock import MockerFixture |
9 | 10 | from rest_framework import status
|
10 | 11 | from rest_framework.test import APIClient
|
11 | 12 |
|
12 | 13 | from environments.dynamodb.types import ProjectIdentityMigrationStatus
|
13 | 14 | from environments.identities.models import Identity
|
| 15 | +from environments.models import Environment |
14 | 16 | from features.models import Feature, FeatureSegment
|
15 | 17 | from organisations.models import Organisation, OrganisationRole
|
16 | 18 | from organisations.permissions.models import (
|
@@ -783,3 +785,25 @@ def test_get_project_data_by_id(
|
783 | 785 | assert response_json["total_features"] == num_features
|
784 | 786 | assert response_json["total_segments"] == num_segments
|
785 | 787 | assert response_json["show_edge_identity_overrides_for_feature"] is False
|
| 788 | + |
| 789 | + |
| 790 | +def test_delete_project__calls_expected( |
| 791 | + admin_client: APIClient, |
| 792 | + project: Project, |
| 793 | + environment: Environment, |
| 794 | + mocker: MockerFixture, |
| 795 | +) -> None: |
| 796 | + # Given |
| 797 | + url = reverse("api-v1:projects:project-detail", args=[project.id]) |
| 798 | + |
| 799 | + delete_environment_mock = mocker.patch("projects.views.delete_environment") |
| 800 | + |
| 801 | + # When |
| 802 | + admin_client.delete(url) |
| 803 | + |
| 804 | + # Then |
| 805 | + project.refresh_from_db() |
| 806 | + assert project.deleted |
| 807 | + delete_environment_mock.delay.assert_called_once_with( |
| 808 | + kwargs={"environment_id": environment.id} |
| 809 | + ) |
0 commit comments