Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
9066d31a
Commit
9066d31a
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Reformat
parent
0ed66417
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!464
Resolve "Support PDF generation via a headless Chromium running in the background using celery"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/tests/browser/test_selenium.py
+3
-3
3 additions, 3 deletions
aleksis/core/tests/browser/test_selenium.py
aleksis/core/tests/models/test_pdffile.py
+28
-0
28 additions, 0 deletions
aleksis/core/tests/models/test_pdffile.py
with
31 additions
and
3 deletions
aleksis/core/tests/browser/test_selenium.py
+
3
−
3
View file @
9066d31a
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/tests/models/test_pdffile.py
0 → 100644
+
28
−
0
View file @
9066d31a
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)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment