Skip to content

Commit

Permalink
Create test for missing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed Oct 31, 2024
1 parent 0d3a603 commit 02f5a6d
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from integrations.github.constants import GITHUB_API_URL, GITHUB_API_VERSION
from integrations.github.models import GithubConfiguration, GitHubRepository
from projects.models import Project
from projects.tags.models import Tag
from segments.models import Segment
from tests.types import WithEnvironmentPermissionsCallable
from users.models import FFAdminUser
Expand Down Expand Up @@ -77,6 +78,7 @@ def test_create_feature_external_resource(
post_request_mock: MagicMock,
mock_github_client_generate_token: MagicMock,
) -> None:

# Given
repository_owner_name = (
f"{github_repository.repository_owner}/{github_repository.repository_name}"
Expand Down Expand Up @@ -181,6 +183,49 @@ def test_create_feature_external_resource(
)


@responses.activate
def test_create_feature_external_resource_missing_tags(
admin_client_new: APIClient,
feature_with_value: Feature,
segment_override_for_feature_with_value: FeatureState,
environment: Environment,
project: Project,
github_configuration: GithubConfiguration,
github_repository: GitHubRepository,
post_request_mock: MagicMock,
mock_github_client_generate_token: MagicMock,
) -> None:

# Given
Tag.objects.all().delete()
repository_owner_name = (
f"{github_repository.repository_owner}/{github_repository.repository_name}"
)
feature_external_resource_data = {
"type": "GITHUB_ISSUE",
"url": f"https://github.com/{repository_owner_name}/issues/35",
"feature": feature_with_value.id,
"metadata": {"state": "open"},
}

url = reverse(
"api-v1:projects:feature-external-resources-list",
kwargs={"project_pk": project.id, "feature_pk": feature_with_value.id},
)

# When
response = admin_client_new.post(
url, data=feature_external_resource_data, format="json"
)

# Then
assert response.status_code == status.HTTP_201_CREATED
assert Tag.objects.count() == 1
tag = Tag.objects.first()
assert tag.project == project
assert tag.label == "Issue Open"


def test_cannot_create_feature_external_resource_with_an_invalid_gh_url(
admin_client_new: APIClient,
feature: Feature,
Expand Down

0 comments on commit 02f5a6d

Please sign in to comment.