Skip to content

Commit 27e019e

Browse files
committed
all: use test.sh to encapsulate tests
1 parent d2e8941 commit 27e019e

16 files changed

Lines changed: 48 additions & 34 deletions

File tree

api/School-Secretary/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Permitir mais campos em POST para deleção em massa no admin
2-
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
32
"""
43
Django settings for School-Secretary project.
54
@@ -11,11 +10,12 @@
1110
For the full list of settings and their values, see
1211
https://docs.djangoproject.com/en/5.1/ref/settings/
1312
"""
14-
1513
import os
1614
from datetime import timedelta
1715
from pathlib import Path
1816

17+
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
18+
1919
# Build paths inside the project like this: BASE_DIR / 'subdir'.
2020
BASE_DIR = Path(__file__).resolve().parent.parent
2121

api/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ dependencies = [
6262
"xhtml2pdf==0.2.17",
6363
"zopfli==0.2.3.post1",
6464
]
65+
66+
[dependency-groups]
67+
dev = [
68+
"ruff>=0.14.4",
69+
]

api/school/tests/test_serializers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from rest_framework.test import APITestCase
2-
from rest_framework import serializers
32
from school.serializers import (
43
SubjectCompactSerializer,
54
ItineraryCompactSerializer,

api/school/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.urls import include, path
21
from rest_framework.routers import DefaultRouter
32

43
from .views import (

api/school/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from users.permissions import IsProfessor, IsStaff
88
from utils.date import get_day_name
99
from utils.reports import (
10-
calculate_approval_rate,
11-
calculate_dropout_rate,
1210
generate_efficiency_analysis,
1311
generate_group_performance_report,
1412
)

api/students/tests/test_serializers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from rest_framework.test import APITestCase
2-
from rest_framework import serializers
32
from students.serializers import (
43
StudentCompactSerializer,
54
GuardianCompactSerializer,
@@ -15,7 +14,6 @@
1514
from school.models import Group, Subject
1615
from django.contrib.auth import get_user_model
1716
from django.utils import timezone
18-
import datetime
1917

2018

2119
class StudentSerializersTest(APITestCase):

api/students/views.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def download_grades_pdf(self, request, pk=None):
8686
# Initialize with None for each bimester
8787
bimester_grades = [None, None, None, None]
8888
for grade in all_grades.filter(subject__full_name=subject):
89-
bimester_num = int(grade.bimester[0]) # Extract the numeric part (e.g., "1B" -> 1)
89+
bimester_num = int(
90+
grade.bimester[0]
91+
) # Extract the numeric part (e.g., "1B" -> 1)
9092
if 1 <= bimester_num <= 4:
9193
bimester_grades[bimester_num - 1] = grade.value
9294
data[subject] = bimester_grades
@@ -102,7 +104,7 @@ def download_presence_pdf(self, request, pk=None):
102104
current_year = timezone.now().year
103105
presence_records = Presence.objects.filter(
104106
student=student, date__year=current_year
105-
).order_by('date')
107+
).order_by("date")
106108
return pdfgen(
107109
"presence.html",
108110
{"student": student, "data": presence_records},
@@ -128,7 +130,7 @@ def download_academic_report(self, request, pk=None):
128130
"grades": report["grades"],
129131
"attendance": report["attendance"],
130132
"discipline": report["discipline"],
131-
"now": tz.now(),
133+
"now": timezone.now(),
132134
}
133135

134136
return pdfgen(
@@ -375,7 +377,7 @@ def download_financial_report(self, request):
375377
"student": student,
376378
"summary": report["summary"],
377379
"payment_history": report["payment_history"],
378-
"now": tz.now(),
380+
"now": timezone.now(),
379381
}
380382

381383
filename = (

api/test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
6+
7+
cd $SCRIPT_DIR
8+
9+
echo "--- Executing API code checking ---"
10+
uv run ruff check .
11+
12+
echo "--- Executing API tests ---"
13+
uv run python manage.py test

api/users/forms.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django import forms
21
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
32

43
from .models import User

api/users/serializers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from django.contrib.auth import get_user_model
22
from rest_framework import serializers
33

4-
from school.models import Professor
54
from school.serializers import ProfessorSerializer
6-
from students.models import Guardian, Student
75
from students.serializers import GuardianSerializer, StudentSerializer
86

97

0 commit comments

Comments
 (0)