Skip to content
Snippets Groups Projects
Commit 9066d31a authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Reformat

parent 0ed66417
No related branches found
No related tags found
1 merge request!464Resolve "Support PDF generation via a headless Chromium running in the background using celery"
......@@ -19,6 +19,7 @@ SeleniumTestCaseBase.browsers = list(
)
SeleniumTestCaseBase.selenium_hub = os.environ.get("TEST_SELENIUM_HUB", "") or None
@pytest.mark.usefixtures("celery_worker")
@override_settings(CELERY_BROKER_URL="memory://localhost//")
class SeleniumTests(SeleniumTestCase):
......@@ -35,7 +36,7 @@ class SeleniumTests(SeleniumTestCase):
else:
return False
def _login(self, username= "admin", password= "admin", with_screenshots=False):
def _login(self, username="admin", password="admin", with_screenshots=False):
# Navigate to configured login page
self.selenium.get(self.live_server_url + reverse(settings.LOGIN_URL))
if with_screenshots:
......@@ -56,7 +57,7 @@ class SeleniumTests(SeleniumTestCase):
if with_screenshots:
self._screenshot("login_default_superuser_submitted.png")
def _create_person(self, username = "admin"):
def _create_person(self, username="admin"):
user = User.objects.get(username=username)
person = Person.objects.create(user=user, first_name="Jane", last_name="Doe")
return person
......@@ -66,7 +67,6 @@ class SeleniumTests(SeleniumTestCase):
assert "AlekSIS" in self.selenium.title
self._screenshot("index.png")
def test_login_default_superuser(self):
self._login("admin", "admin", with_screenshots=True)
......
import re
from datetime import datetime
from django.template.loader import render_to_string
from django.utils import timezone
import pytest
from aleksis.core.models import PDFFile, Person
pytestmark = pytest.mark.django_db
def _get_test_html():
return render_to_string("core/pages/test_pdf.html")
def test_pdf_generation():
dummy_person = Person.objects.create(first_name="Jane", last_name="Doe")
html = _get_test_html()
assert "html" in html
file_object = PDFFile.objects.create(person=dummy_person, html=html)
assert isinstance(file_object.expires_at, datetime)
assert file_object.expires_at > timezone.now()
assert not bool(file_object.file)
# generate_pdf(file_object.pk, html)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment