-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Upgrade DRF, Cypress and switch to pypdf
- Loading branch information
1 parent
b29396d
commit 349c43e
Showing
6 changed files
with
249 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"cypress": "^12.0.0" | ||
"cypress": "^13.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
from datetime import date, datetime, timedelta | ||
from unittest.mock import ANY, Mock, patch | ||
|
||
import PyPDF2 | ||
import pytest | ||
from common.mail import campaign_ids | ||
from common.models import ( | ||
Class, | ||
DailyActivity, | ||
|
@@ -16,7 +16,6 @@ | |
UserProfile, | ||
UserSession, | ||
) | ||
from common.mail import campaign_ids | ||
from common.tests.utils.classes import create_class_directly | ||
from common.tests.utils.organisation import ( | ||
create_organisation_directly, | ||
|
@@ -35,6 +34,7 @@ | |
from game.models import Level | ||
from game.tests.utils.attempt import create_attempt | ||
from game.tests.utils.level import create_save_level | ||
from pypdf import PdfReader | ||
from rest_framework.test import APIClient, APITestCase | ||
|
||
from deploy import captcha | ||
|
@@ -93,10 +93,10 @@ def test_reminder_cards(self): | |
|
||
# read PDF, check there's only 1 page and that the correct student details show | ||
with io.BytesIO(response.content) as pdf_file: | ||
file_reader = PyPDF2.PdfFileReader(pdf_file) | ||
assert file_reader.getNumPages() == 1 | ||
file_reader = PdfReader(pdf_file) | ||
assert len(file_reader.pages) == 1 | ||
|
||
page_text = file_reader.getPage(0).extractText() | ||
page_text = file_reader.pages[0].extract_text() | ||
assert NAME1 in page_text | ||
assert NAME2 in page_text | ||
assert PASSWORD1 in page_text | ||
|
@@ -119,11 +119,11 @@ def test_reminder_cards(self): | |
|
||
# Check there are 2 pages and that each page contains the warning text | ||
with io.BytesIO(response.content) as pdf_file: | ||
file_reader = PyPDF2.PdfFileReader(pdf_file) | ||
assert file_reader.getNumPages() == 2 | ||
file_reader = PdfReader(pdf_file) | ||
assert len(file_reader.pages) == 2 | ||
|
||
page1_text = file_reader.getPage(0).extractText() | ||
page2_text = file_reader.getPage(1).extractText() | ||
page1_text = file_reader.pages[0].extract_text() | ||
page2_text = file_reader.pages[1].extract_text() | ||
assert REMINDER_CARDS_PDF_WARNING_TEXT in page1_text | ||
assert REMINDER_CARDS_PDF_WARNING_TEXT in page2_text | ||
|
||
|
@@ -252,20 +252,24 @@ def test_release_verified_student(self): | |
assert response.status_code == 302 | ||
|
||
student = Student.objects.get(pk=self.student.pk) | ||
|
||
assert student.user.is_verified | ||
|
||
c.logout() | ||
c.login(username=self.email, password=self.password) | ||
|
||
teacher = Teacher.objects.factory("the", "teacher", "[email protected]", "password") | ||
teacher = Teacher.objects.factory( | ||
"the", "teacher", "[email protected]", "password" | ||
) | ||
level = Level.objects.create() | ||
|
||
level.owner = student.new_user.userprofile | ||
level.shared_with.add(teacher.new_user) | ||
level.save() | ||
|
||
students_levels = Level.objects.filter(owner=student.new_user.userprofile).all() | ||
students_levels = Level.objects.filter( | ||
owner=student.new_user.userprofile | ||
).all() | ||
|
||
for level in students_levels.all(): | ||
assert level.shared_with.exists() | ||
|
@@ -292,7 +296,9 @@ def test_release_verified_student(self): | |
student = Student.objects.get(pk=self.student.pk) | ||
assert not student.user.is_verified | ||
|
||
students_levels = Level.objects.filter(owner=student.new_user.userprofile).all() | ||
students_levels = Level.objects.filter( | ||
owner=student.new_user.userprofile | ||
).all() | ||
|
||
for level in students_levels.all(): | ||
assert not level.shared_with.exists() | ||
|
Oops, something went wrong.