Skip to content

Commit

Permalink
poprawki testów
Browse files Browse the repository at this point in the history
czemu podczas testów te struktury danych są inne??
  • Loading branch information
Acors24 committed Nov 23, 2024
1 parent 75fe5a6 commit e95768d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions zapisy/apps/theses/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ def __init__(self, user, *args, **kwargs):

def clean(self):
self.data = self.data.copy()
if len(self.data['assigned_students'].strip()) != 0:
self.data.setlist('students', self.data['assigned_students'].split(','))
if 'assigned_students' in self.data and len(self.data['assigned_students'].strip()) != 0:
if 'setlist' in self.data:
self.data.setlist('students', self.data['assigned_students'].split(','))
else:
self.data['students'] = self.data['assigned_students'].split(',')
super().clean()
if len(self.cleaned_data['assigned_students'].strip()) != 0:
if 'assigned_students' in self.data and len(self.cleaned_data['assigned_students'].strip()) != 0:
self.cleaned_data['students'] = Student.objects.filter(
id__in=self.cleaned_data['assigned_students'].split(',')
)
Expand Down
10 changes: 5 additions & 5 deletions zapisy/apps/theses/tests/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_edit(self):
form_data_0 = {'title': thesis_edit_0.title,
'advisor': thesis_edit_0.advisor_id, 'kind': 0,
'reserved_until': timezone.now(),
'students': [StudentFactory()],
'assigned_students': f'{StudentFactory().id}',
'status': ThesisStatus.ACCEPTED.value,
'max_number_of_students': 2}
form_data_1 = {'title': thesis_edit_1.title,
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_max_number_of_students_not_valid(self):
form_data = {'title': 'Praca dyplomowa',
'advisor': self.thesis_owner, 'kind': 0,
'reserved_until': timezone.now(),
'students': [StudentFactory(), StudentFactory(), StudentFactory()],
'assigned_students': f'{StudentFactory().id},{StudentFactory().id},{StudentFactory().id}',
'max_number_of_students': 2}

thesis_form = ThesisForm(user=self.thesis_owner.user, data=form_data)
Expand All @@ -129,7 +129,7 @@ def test_max_number_of_students_valid(self):
form_data = {'title': 'Praca dyplomowa',
'advisor': self.thesis_owner, 'kind': 0,
'reserved_until': timezone.now(),
'students': [StudentFactory(), StudentFactory()],
'assigned_students': f'{StudentFactory().id},{StudentFactory().id}',
'max_number_of_students': 2}

thesis_form = ThesisForm(user=self.thesis_owner.user, data=form_data)
Expand All @@ -141,7 +141,7 @@ def test_max_number_of_students_valid(self):
def test_reservation_date_not_valid(self):
form_data_0 = {'title': 'Praca dyplomowa_0',
'advisor': self.thesis_owner, 'kind': 0,
'students': [StudentFactory(), StudentFactory()],
'assigned_students': f'{StudentFactory().id},{StudentFactory().id}',
'max_number_of_students': 2}

form_data_1 = {'title': 'Praca dyplomowa_1',
Expand All @@ -159,7 +159,7 @@ def test_reservation_date_valid(self):
form_data_0 = {'title': 'Praca dyplomowa_0',
'advisor': self.thesis_owner, 'kind': 0,
'reserved_until': timezone.now(),
'students': [StudentFactory(), StudentFactory()],
'assigned_students': f'{StudentFactory().id},{StudentFactory().id}',
'max_number_of_students': 2}

form_data_1 = {'title': 'Praca dyplomowa_1',
Expand Down

0 comments on commit e95768d

Please sign in to comment.