Skip to content

Commit

Permalink
Add transaction to test decorators + misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Sep 4, 2024
1 parent 16a1ff0 commit 9e5ef2a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion backend/backend/custom_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
please check the path: backend/backend/settings.py
"""

# Pagination settings
# MARK: Pagination

PAGINATION_PAGE_SIZE = 20
PAGINATION_MAX_PAGE_SIZE = 100
2 changes: 1 addition & 1 deletion backend/backend/exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def bad_request_logger(exception: Any, context: dict[str, Any]) -> Response | None:
# Get the DRF exception handler standard error response
# Get the DRF exception handler standard error response.
response = exception_handler(exception, context)

if response is not None:
Expand Down
4 changes: 2 additions & 2 deletions backend/backend/management/commands/populate_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:
number_of_events = options["events"]
number_of_groups = options["groups"]

# Clear all tables before creating new data
# Clear all tables before creating new data.
UserModel.objects.exclude(username="admin").delete()
Organization.objects.all().delete()
Event.objects.all().delete()
Expand All @@ -55,6 +55,6 @@ def handle(self, *args: str, **options: Unpack[Options]) -> None:
except Exception as error:
self.stdout.write(
self.style.ERROR(
f"An error occured during the creation of dummy data: {error}"
f"An error occurred during the creation of dummy data: {error}"
)
)
2 changes: 1 addition & 1 deletion backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
EMAIL_PORT = os.getenv("EMAIL_PORT")
EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD")
EMAIL_USE_TLS = bool(os.getenv("EMAIL_USE_TLS") == "True")
EMAIL_USE_TLS = os.getenv("EMAIL_USE_TLS") == "True"
# DEVELOPMENT ONLY
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

Expand Down
3 changes: 1 addition & 2 deletions backend/backend/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

@pytest.fixture
def api_client() -> APIClient:
client = APIClient()
return client
return APIClient()
4 changes: 2 additions & 2 deletions backend/content/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def validate(self, data: Dict[str, Union[str, int]]) -> Dict[str, Union[str, int
with PilImage.open(data["image_location"]) as img:
img.verify()
img_format = img.format.lower()
except Exception:
except Exception as e:
raise serializers.ValidationError(
_("The image is not valid."), code="corrupted_file"
)
) from e

if img_format not in image_extensions:
raise serializers.ValidationError(
Expand Down
4 changes: 2 additions & 2 deletions backend/entities/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
)


@pytest.mark.django_db
@pytest.mark.django_db(transaction=True)
def test_str_methods() -> None:
organization = OrganizationFactory.build()
# Needs to be updated to reflect the recent changes
# Note: Needs to be updated to reflect the recent changes.
# organization_application = OrganizationApplicationFactory.build()
organization_event = OrganizationEventFactory.build()
organization_member = OrganizationMemberFactory.build()
Expand Down
1 change: 1 addition & 0 deletions backend/events/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)


@pytest.mark.django_db(transaction=True)
def test_str_methods() -> None:
event = EventFactory.build()
event_attendee = EventAttendeeFactory.build()
Expand Down

0 comments on commit 9e5ef2a

Please sign in to comment.