diff --git a/concerts/tests/features/api.feature b/concerts/tests/features/api.feature index 0cdc094..c3b0077 100644 --- a/concerts/tests/features/api.feature +++ b/concerts/tests/features/api.feature @@ -12,11 +12,11 @@ Feature: API Endpoints When I request the list Then I should receive a list of entities - Examples: - | entity | - | artist | - | venue | - | concert | + Examples: + | entity | + | artist | + | venue | + | concert | @api Scenario: Retrieve a user's concert reviews list @@ -26,6 +26,13 @@ Feature: API Endpoints When Alice requests the list of concert reviews for Sam Then the response should contain an empty list of reviews + Scenario: Create international venue through API + Given I have a registered user Bob + And I am a token authenticated user Bob + When I create a new venue with {"name": "International Venue", "city": "Paris", "country": "FR"} + Then the response status code should be 201 + And the state of the created venue should be None + @api Scenario: Update a user's own concert review Given I have a registered user Sam diff --git a/concerts/tests/features/steps/common.py b/concerts/tests/features/steps/common.py index e4c2bc5..8197360 100644 --- a/concerts/tests/features/steps/common.py +++ b/concerts/tests/features/steps/common.py @@ -1,4 +1,4 @@ -from behave import given, then +from behave import given, step, then from django.contrib.auth import get_user_model from django.urls import reverse from rest_framework.authtoken.models import Token @@ -82,6 +82,15 @@ def step_impl(context, status_code): ), f"Expected {status_code} but got {context.response.status_code}" +@step("the state of the created venue should be None") +def step_impl(context): + # Get the latest venue created + venue = Venue.objects.order_by("-created_at").first() + + # Check if the state is None + assert venue.state is None, f"Expected venue.state to be None, but got {venue.state}" + + def after_scenario(context, _): User = get_user_model() User.objects.exclude(username="testuser").delete() diff --git a/concerts/tests/features/steps/webviews.py b/concerts/tests/features/steps/webviews.py index d05018b..e4a27f7 100644 --- a/concerts/tests/features/steps/webviews.py +++ b/concerts/tests/features/steps/webviews.py @@ -106,3 +106,10 @@ def step_impl(context, entity_type, invalid_data): @then("I should see form errors in the response") def step_impl(context): assert "This field is required." in context.response.content.decode(), "Expected form errors, but none were found." + + +@when("I create an international venue with valid data") +def step_impl(context): + data = {"name": "Test International Venue", "city": "Test City", "country": "FR"} + url = reverse("concerts:venue-create") + context.response = context.client.post(url, data=data) diff --git a/concerts/tests/features/webviews.feature b/concerts/tests/features/webviews.feature index 536ead7..83306e8 100644 --- a/concerts/tests/features/webviews.feature +++ b/concerts/tests/features/webviews.feature @@ -1,6 +1,6 @@ Feature: List Views -Scenario Outline: Authenticated user can view a list of entities + Scenario Outline: Authenticated user can view a list of entities Given I have a registered user "testuser" And "testuser" is logged in And there is a in the system @@ -8,25 +8,33 @@ Scenario Outline: Authenticated user can view a list of entities Then the response status code should be 200 Examples: - | entity_type | - | concert | - | artist | - | venue | + | entity_type | + | concert | + | artist | + | venue | -Scenario Outline: Authenticated user can create entities + Scenario Outline: Authenticated user can create entities Given I have a registered user "testuser" And "testuser" is logged in When I make a new with valid data Then the response status code should be 302 Examples: - | entity_type | - | concert | - | artist | - | venue | - | review | + | entity_type | + | concert | + | artist | + | venue | + | review | -Scenario Outline: Authenticated user can view details of entities + Scenario: Authenticated user can create an international venue + Given I have a registered user "testuser" + And "testuser" is logged in + When I create an international venue with valid data + Then the response status code should be 302 + And the state of the created venue should be None + + + Scenario Outline: Authenticated user can view details of entities Given I have a registered user "testuser" And "testuser" is logged in And there is a in the system @@ -34,20 +42,20 @@ Scenario Outline: Authenticated user can view details of entities Then the response status code should be 200 Examples: - | entity_type | - | concert | - | artist | - | venue | - | review | + | entity_type | + | concert | + | artist | + | venue | + | review | -Scenario: Authenticated user can attend a concert + Scenario: Authenticated user can attend a concert Given I have a registered user "testuser" And "testuser" is logged in And there is a concert in the system When I attend the concert Then the response status code should be 302 -Scenario: Authenticated user can unattend a concert + Scenario: Authenticated user can unattend a concert Given I have a registered user "testuser" And "testuser" is logged in And there is a concert in the system @@ -55,7 +63,7 @@ Scenario: Authenticated user can unattend a concert When I unattend the concert Then the response status code should be 302 -Scenario Outline: Authenticated user cannot create entities with invalid data + Scenario Outline: Authenticated user cannot create entities with invalid data Given I have a registered user "testuser" And "testuser" is logged in When I attempt to make a new with data @@ -63,8 +71,8 @@ Scenario Outline: Authenticated user cannot create entities with invalid data Then I should see form errors in the response Examples: - | entity_type | invalid_data | - | concert | { "artist": "", "venue": "" } | - | artist | { "name": "" } | - | venue | { "name": "", "city": "", "state": "", "country": ""}| + | entity_type | invalid_data | + | concert | { "artist": "", "venue": "" } | + | artist | { "name": "" } | + | venue | { "name": "", "city": "", "state": "", "country": ""} |