Skip to content

Commit d4c33ab

Browse files
Fixed tests and logout action
1 parent 83b06bc commit d4c33ab

54 files changed

Lines changed: 5367 additions & 1888 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

calcus/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218

219219
WSGI_APPLICATION = "calcus.wsgi.application"
220220

221-
if IS_CLOUD:
221+
if IS_CLOUD and not IS_TEST:
222222
DATABASES = {
223223
"default": {
224224
"ENGINE": "django_cockroachdb",

frontend/templates/frontend/base.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@
319319
{% if user.is_authenticated %}
320320
<a href="{% url 'frontend:profile' %}"> &nbsp;<strong>My Profile</strong></a>
321321
&nbsp;&nbsp;&nbsp;&nbsp;
322-
<a href="{% url 'logout'%}?next={{request.path}}">Logout <i class="fas fa-sign-out-alt"></i></a>
322+
<form action="{% url 'logout' %}?next={{ request.path }}" method="post">
323+
{% csrf_token %}
324+
<button class="button" type="submit">Logout <i class="fas fa-sign-out-alt"></i></button>
325+
</form>
323326
{% else %}
324327
<a class="button is-primary" href="{% url 'frontend:register' %}">
325328
<strong>Register</strong>

frontend/test_selenium.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,39 @@ class InterfaceTests(CalcusLiveServer):
5252
def test_default_login_page(self):
5353
self.assertTrue(self.is_on_page_projects())
5454

55+
def test_logout(self):
56+
self.lget("/projects/")
57+
58+
logout_button = WebDriverWait(self.driver, 5).until(
59+
EC.element_to_be_clickable(
60+
(
61+
By.XPATH,
62+
"//form[contains(@action, 'logout')]//button[contains(normalize-space(.), 'Logout')]",
63+
)
64+
)
65+
)
66+
logout_button.click()
67+
68+
WebDriverWait(self.driver, 5).until(
69+
lambda d: len(
70+
d.find_elements(By.XPATH, "//a[contains(normalize-space(.), 'Log in')]")
71+
)
72+
> 0
73+
and len(
74+
d.find_elements(
75+
By.XPATH,
76+
"//form[contains(@action, 'logout')]//button[contains(normalize-space(.), 'Logout')]",
77+
)
78+
)
79+
== 0
80+
)
81+
82+
self.lget("/projects/")
83+
WebDriverWait(self.driver, 5).until(
84+
EC.presence_of_element_located((By.ID, "id_username"))
85+
)
86+
self.assertIn("/accounts/login/", self.driver.current_url)
87+
5588
def test_goto_projects(self):
5689
self.lget("/projects/")
5790
self.assertTrue(self.is_on_page_projects())

frontend/tests/cache/frontend.test_calculations.XtbCalculationTests.test_NEB.input

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
!NEB xtb2 --nimages 3
2+
!NEB xtb2
33
*xyz -1 1
44
C -0.74277000 0.14309000 0.12635000
55
C 0.71308000 -0.12855000 -0.16358000
@@ -13,8 +13,8 @@ O -0.91651000 0.74066000 3.00993000
1313
H -1.82448000 0.94856000 3.28105000
1414
*
1515
%neb
16+
nimages 3
1617
product "calc2.xyz"
17-
nimages 8
1818
end
1919
%pal
2020
nprocs 4

frontend/tests/cache/frontend.test_calculations.XtbCalculationTests.test_NEB/calc.inp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
!NEB xtb2 --nimages 3
1+
!NEB xtb2
22
*xyz -1 1
33
C -0.74277000 0.14309000 0.12635000
44
C 0.71308000 -0.12855000 -0.16358000
@@ -12,8 +12,8 @@ O -0.91651000 0.74066000 3.00993000
1212
H -1.82448000 0.94856000 3.28105000
1313
*
1414
%neb
15+
nimages 3
1516
product "calc2.xyz"
16-
nimages 8
1717
end
1818
%pal
1919
nprocs 4

0 commit comments

Comments
 (0)