Skip to content
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/test.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- review_requested
branches:
- main
- develop

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/apis/v1/forms/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from django.utils import timezone

from apps.forms.models import Component
from tests.apis.factories import ComponentFactory
from tests.apis.factories import FormFactory
from tests.factories import ComponentFactory
from tests.factories import FormFactory


@pytest.fixture
Expand Down
27 changes: 17 additions & 10 deletions backend/tests/apis/v1/forms/form_create.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@django_db
Feature: Form Create Test
Background:
Given The data to be sent is as follows.
Scenario Outline: Form Create Permission Test
Given I am a <user_type> user.
And I am logged in.
And The following data will be sent.
"""
{
"slug": "test",
Expand All @@ -10,11 +12,7 @@ Feature: Form Create Test
"end_date": "2023-12-31"
}
"""

Scenario Outline: Form Create Permission Test
Given I am a/an <user_type> user.
And I am logging in.
When I am making a request to the server with data using the POST and /v1/forms/.
When I am sending a POST request to /v1/forms/ with data.
Then The response status code is <status_code>.
Examples:
| user_type | status_code |
Expand All @@ -23,9 +21,18 @@ Feature: Form Create Test
| staff | 201 |

Scenario: Form Create Test
Given I am a/an staff user.
And I am logging in.
When I am making a request to the server with data using the POST and /v1/forms/.
Given I am a staff user.
And I am logged in.
And The following data will be sent.
"""
{
"slug": "test",
"title": "test",
"start_date": "2023-12-01",
"end_date": "2023-12-31"
}
"""
When I am sending a POST request to /v1/forms/ with data.
Then The response status code is 201.
And The slug data in the response JSON is the same as test.
And The title data in the response JSON is of type str and the same as test.
18 changes: 9 additions & 9 deletions backend/tests/apis/v1/forms/form_delete.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@django_db
Feature: Form Delete Test
Background:
Given I will save the following data using backend.tests.apis.factories's FormFactory.
Given I will save the following data using Form model.
"""
{
"id": 1,
"id": 101,
"slug": "test",
"title": "test",
"start_date": "2023-12-01",
Expand All @@ -13,9 +13,9 @@ Feature: Form Delete Test
"""

Scenario Outline: Form Delete Permission Test
Given I am a/an <user_type> user.
And I am logging in.
When I am making a request to the server using the DELETE and /v1/forms/test/.
Given I am a <user_type> user.
And I am logged in.
When I am making a DELETE request to /v1/forms/test/.
Then The response status code is <status_code>.
Examples:
| user_type | status_code |
Expand All @@ -24,8 +24,8 @@ Feature: Form Delete Test
| staff | 204 |

Scenario: Form Delete Test
Given I am a/an staff user.
And I am logging in.
When I am making a request to the server using the DELETE and /v1/forms/test/.
Given I am a staff user.
And I am logged in.
When I am making a DELETE request to /v1/forms/test/.
Then The response status code is 204.
And The existence of data with an ID of 1 in the Form model from apps.forms.models is False.
And It is False that a record with an ID of 101 exists in the Form model from apps.forms.models.
22 changes: 11 additions & 11 deletions backend/tests/apis/v1/forms/form_list.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@django_db
Feature: Form List Test
Background:
Given I will save the following data using backend.tests.apis.factories's FormFactory.
Given I will save the following data using Form model.
"""
{
"id": 1,
"id": 101,
"slug": "test",
"title": "test",
"start_date": "2023-12-01",
Expand All @@ -13,9 +13,9 @@ Feature: Form List Test
"""

Scenario Outline: Form List Permission Test
Given I am a/an <user_type> user.
And I am logging in.
When I am making a request to the server using the GET and /v1/forms/.
Given I am a <user_type> user.
And I am logged in.
When I am making a GET request to /v1/forms/.
Then The response status code is <status_code>.
Examples:
| user_type | status_code |
Expand All @@ -24,10 +24,10 @@ Feature: Form List Test
| staff | 200 |

Scenario: Form List Test
Given I am a/an general user.
And I am logging in.
When I am making a request to the server using the GET and /v1/forms/.
Given I am a general user.
And I am logged in.
When I am making a GET request to /v1/forms/.
Then The response status code is 200.
And The number of result in the response JSON is 1.
And The slug data in the 1st/nd/rd/th entry of the response JSON list is the same as test.
And The title data in the 1st/nd/rd/th entry of the response JSON list is of type str and the same as test.
And The number of results in the response JSON is 1.
And The slug data in the 1th entry of the response JSON list is the same as test.
And The title data in the 1th entry of the response JSON list is of type str and the same as test.
47 changes: 47 additions & 0 deletions backend/tests/apis/v1/forms/form_partial_update.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@django_db
Feature: Form Partial Update Test
Background:
Given I will save the following data using Form model.
"""
{
"id": 101,
"slug": "test",
"title": "test",
"start_date": "2023-12-01",
"end_date": "2023-12-31"
}
"""

Scenario Outline: Form Partial Update Permission Test
Given I am a <user_type> user.
And I am logged in.
And The following data will be sent.
"""
{
"title": "test1"
}
"""
When I am sending a PATCH request to /v1/forms/test/ with data.
Then The response status code is <status_code>.
Examples:
| user_type | status_code |
| anonymous | 403 |
| general | 403 |
| staff | 200 |


Scenario: Form Partial Update Test
Given I am a staff user.
And I am logged in.
And The following data will be sent.
"""
{
"title": "test2"
}
"""
When I am sending a PATCH request to /v1/forms/test/ with data.
Then The response status code is 200.
And The id data in the response JSON is the same as 101.
And The title data in the response JSON is the same as test2.
And It is True that a record with an ID of 101 exists in the Form model from apps.forms.models.
And The title field of the Form model from apps.forms.models with an ID of 101 is of type str and equals test2.
4 changes: 2 additions & 2 deletions backend/tests/apis/v1/forms/form_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def test_form_create_test():
pass


@scenario("form_update.feature", "Form Partial Update Permission Test")
@scenario("form_partial_update.feature", "Form Partial Update Permission Test")
def test_form_partial_update_permission_test():
pass


@scenario("form_update.feature", "Form Partial Update Test")
@scenario("form_partial_update.feature", "Form Partial Update Test")
def test_form_partial_update_test():
pass

Expand Down
41 changes: 0 additions & 41 deletions backend/tests/apis/v1/forms/form_update.feature

This file was deleted.

4 changes: 2 additions & 2 deletions backend/tests/apis/v1/forms/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from apis.v1.forms.serializers import SubmitSerializer, FormSerializer
from apps.forms.models import Choice
from apps.forms.models import Component
from tests.apis.factories import ChoiceFactory
from tests.apis.factories import ComponentFactory
from tests.factories import ChoiceFactory
from tests.factories import ComponentFactory


class TestFormSerializer:
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/apis/v1/forms/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from rest_framework.reverse import reverse

from apps.forms.models import Component, Choice
from tests.apis.factories import ComponentFactory, ChoiceFactory
from tests.factories import ComponentFactory, ChoiceFactory


@pytest.mark.urls(urls="apis.v1.urls")
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/apps/forms/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

from apps.forms.models import Component
from apps.forms.tasks import get_dataframe
from tests.apis.factories import ComponentFactory
from tests.apis.factories import FormFactory
from tests.apis.factories import SubmitFactory, AnswerFactory, ChoiceFactory, UserFactory
from tests.factories import ComponentFactory
from tests.factories import FormFactory
from tests.factories import SubmitFactory, AnswerFactory, ChoiceFactory, UserFactory


@pytest.mark.django_db
Expand Down
Loading
Loading