Skip to content

Commit fca03d3

Browse files
authored
Merge pull request #768 from python-discord/fix-warnings
Fix Warnings & Enable In Tests
2 parents e538d96 + 42b9f8d commit fca03d3

File tree

13 files changed

+24
-15
lines changed

13 files changed

+24
-15
lines changed

.github/workflows/lint-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
CI: True
5454
DATABASE_URL: postgres://pysite:pysite@localhost:7777/pysite
5555
METRICITY_DB_URL: postgres://pysite:pysite@localhost:7777/metricity
56+
PYTHONWARNINGS: error
5657

5758
# This step will publish the coverage reports coveralls.io and
5859
# print a "job" link in the output of the GitHub Action

manage.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import django
88
from django.contrib.auth import get_user_model
99
from django.core.management import call_command, execute_from_command_line
10+
from django.test.utils import ignore_warnings
1011

1112
DEFAULT_ENVS = {
1213
"DJANGO_SETTINGS_MODULE": "pydis_site.settings",
@@ -154,7 +155,16 @@ def run_server(self) -> None:
154155
def run_tests(self) -> None:
155156
"""Prepare and run the test suite."""
156157
self.prepare_environment()
157-
call_command(*sys.argv[1:])
158+
# The whitenoise package expects a staticfiles directory to exist during startup,
159+
# else it raises a warning. This is fine under normal application, but during
160+
# tests, staticfiles are not, and do not need to be generated.
161+
# The following line suppresses the warning.
162+
# Reference: https://github.com/evansd/whitenoise/issues/215
163+
with ignore_warnings(
164+
message=r"No directory at: .*staticfiles",
165+
module="whitenoise.base",
166+
):
167+
call_command(*sys.argv[1:])
158168

159169

160170
def clean_up_static_files(build_folder: Path) -> None:

pydis_site/apps/api/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'pydis_site.apps.api.apps.ApiConfig'

pydis_site/apps/api/tests/test_filterlists.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def test_returns_filter_list_types(self):
6464

6565
self.assertEqual(response.status_code, 200)
6666
for api_type, model_type in zip(response.json(), FilterList.FilterListType.choices):
67-
self.assertEquals(api_type[0], model_type[0])
68-
self.assertEquals(api_type[1], model_type[1])
67+
self.assertEqual(api_type[0], model_type[0])
68+
self.assertEqual(api_type[1], model_type[1])
6969

7070

7171
class CreationTests(AuthenticatedAPITestCase):

pydis_site/apps/api/viewsets/bot/aoc_completionist_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ class AocCompletionistBlockViewSet(
7070
serializer_class = AocCompletionistBlockSerializer
7171
queryset = AocCompletionistBlock.objects.all()
7272
filter_backends = (DjangoFilterBackend,)
73-
filter_fields = ("user__id", "is_blocked")
73+
filterset_fields = ("user__id", "is_blocked")

pydis_site/apps/api/viewsets/bot/aoc_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ class AocAccountLinkViewSet(
6868
serializer_class = AocAccountLinkSerializer
6969
queryset = AocAccountLink.objects.all()
7070
filter_backends = (DjangoFilterBackend,)
71-
filter_fields = ("user__id", "aoc_username")
71+
filterset_fields = ("user__id", "aoc_username")

pydis_site/apps/api/viewsets/bot/infraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class InfractionViewSet(
154154
queryset = Infraction.objects.all()
155155
pagination_class = LimitOffsetPaginationExtended
156156
filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter)
157-
filter_fields = ('user__id', 'actor__id', 'active', 'hidden', 'type')
157+
filterset_fields = ('user__id', 'actor__id', 'active', 'hidden', 'type')
158158
search_fields = ('$reason',)
159159
frozen_fields = ('id', 'inserted_at', 'type', 'user', 'actor', 'hidden')
160160

pydis_site/apps/api/viewsets/bot/nomination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class NominationViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge
172172
serializer_class = NominationSerializer
173173
queryset = Nomination.objects.all()
174174
filter_backends = (DjangoFilterBackend, SearchFilter, OrderingFilter)
175-
filter_fields = ('user__id', 'active')
175+
filterset_fields = ('user__id', 'active')
176176
frozen_fields = ('id', 'inserted_at', 'user', 'ended_at')
177177
frozen_on_create = ('ended_at', 'end_reason', 'active', 'inserted_at', 'reviewed')
178178

pydis_site/apps/api/viewsets/bot/reminder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ class ReminderViewSet(
125125
serializer_class = ReminderSerializer
126126
queryset = Reminder.objects.prefetch_related('author')
127127
filter_backends = (DjangoFilterBackend, SearchFilter)
128-
filter_fields = ('active', 'author__id')
128+
filterset_fields = ('active', 'author__id')

pydis_site/apps/api/viewsets/bot/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class UserViewSet(ModelViewSet):
237237
queryset = User.objects.all().order_by("id")
238238
pagination_class = UserListPagination
239239
filter_backends = (DjangoFilterBackend,)
240-
filter_fields = ('name', 'discriminator')
240+
filterset_fields = ('name', 'discriminator')
241241

242242
def get_serializer(self, *args, **kwargs) -> ModelSerializer:
243243
"""Set Serializer many attribute to True if request body contains a list."""

0 commit comments

Comments
 (0)