Skip to content

Commit

Permalink
tests: fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed Aug 31, 2023
1 parent d22766e commit 8be771e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion canaille/templates/macro/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

{% macro pagination(form) %}
<div class="ui right floated buttons pagination">
<form id="{{ id }}" action="{{ url_for(request.url_rule.endpoint, **request.view_args) }}" method="POST">
<form id="{{ form.__class__.__name__|lower }}" action="{{ url_for(request.url_rule.endpoint, **request.view_args) }}" method="POST">
{{ form.hidden_tag() if form.hidden_tag }}
<input type="hidden" name="query" value="{{ form.query.data }}">

Expand Down
18 changes: 8 additions & 10 deletions tests/core/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def test_group_list_pagination(testclient, logged_admin, foo_group):
).text()
assert group_name

form = res.forms["next"]
form["page"] = 2
res = form.submit()
form = res.forms["tableform"]
res = form.submit(name="page", value="2")
assert group_name not in res.pyquery(
".groups tbody tr td:nth-of-type(2) a"
).text().split(" ")
Expand All @@ -35,13 +34,13 @@ def test_group_list_pagination(testclient, logged_admin, foo_group):

def test_group_list_bad_pages(testclient, logged_admin):
res = testclient.get("/groups")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/groups", {"csrf_token": form["csrf_token"].value, "page": "2"}, status=404
)

res = testclient.get("/groups")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/groups", {"csrf_token": form["csrf_token"].value, "page": "-1"}, status=404
)
Expand Down Expand Up @@ -246,9 +245,8 @@ def test_user_list_pagination(testclient, logged_admin, foo_group):
user_name = res.pyquery(".users tbody tr:nth-of-type(1) td:nth-of-type(2) a").text()
assert user_name

form = res.forms["next"]
form["page"] = 2
res = form.submit()
form = res.forms["tableform"]
res = form.submit(name="page", value="2")
assert user_name not in res.pyquery(".users tr td:nth-of-type(2) a").text().split(
" "
)
Expand All @@ -261,13 +259,13 @@ def test_user_list_pagination(testclient, logged_admin, foo_group):

def test_user_list_bad_pages(testclient, logged_admin, foo_group):
res = testclient.get("/groups/foo")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/groups/foo", {"csrf_token": form["csrf_token"].value, "page": "2"}, status=404
)

res = testclient.get("/groups/foo")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/groups/foo",
{"csrf_token": form["csrf_token"].value, "page": "-1"},
Expand Down
9 changes: 4 additions & 5 deletions tests/core/test_profile_edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def test_user_list_pagination(testclient, logged_admin):
user_name = res.pyquery(".users tbody tr:nth-of-type(1) td:nth-of-type(2) a").text()
assert user_name

form = res.forms["next"]
form["page"] = 2
res = form.submit()
form = res.forms["tableform"]
res = form.submit(name="page", value="2")
assert user_name not in res.pyquery(
".users tbody tr td:nth-of-type(2) a"
).text().split(" ")
Expand All @@ -43,13 +42,13 @@ def test_user_list_pagination(testclient, logged_admin):

def test_user_list_bad_pages(testclient, logged_admin):
res = testclient.get("/users")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/users", {"csrf_token": form["csrf_token"].value, "page": "2"}, status=404
)

res = testclient.get("/users")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/users", {"csrf_token": form["csrf_token"].value, "page": "-1"}, status=404
)
Expand Down
9 changes: 4 additions & 5 deletions tests/oidc/test_client_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def test_client_list_pagination(testclient, logged_admin, client, other_client):
).text()
assert client_name

form = res.forms["next"]
form["page"] = 2
res = form.submit()
form = res.forms["tableform"]
res = form.submit(name="form", value="2")
assert client_name not in res.pyquery(
".clients tbody tr td:nth-of-type(2) a"
).text().split(" ")
Expand All @@ -52,15 +51,15 @@ def test_client_list_pagination(testclient, logged_admin, client, other_client):

def test_client_list_bad_pages(testclient, logged_admin):
res = testclient.get("/admin/client")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/admin/client",
{"csrf_token": form["csrf_token"].value, "page": "2"},
status=404,
)

res = testclient.get("/admin/client")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/admin/client",
{"csrf_token": form["csrf_token"].value, "page": "-1"},
Expand Down
9 changes: 4 additions & 5 deletions tests/oidc/test_code_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def test_authorization_list_pagination(testclient, logged_admin, client):
).text()
assert authorization_code_id

form = res.forms["next"]
form["page"] = 2
res = form.submit()
form = res.forms["tableform"]
res = form.submit(name="page", value="2")
assert authorization_code_id not in res.pyquery(
".codes tbody tr td:nth-of-type(1) a"
).text().split(" ")
Expand All @@ -48,15 +47,15 @@ def test_authorization_list_pagination(testclient, logged_admin, client):

def test_authorization_list_bad_pages(testclient, logged_admin):
res = testclient.get("/admin/authorization")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/admin/authorization",
{"csrf_token": form["csrf_token"].value, "page": "2"},
status=404,
)

res = testclient.get("/admin/authorization")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/admin/authorization",
{"csrf_token": form["csrf_token"].value, "page": "-1"},
Expand Down
9 changes: 4 additions & 5 deletions tests/oidc/test_token_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ def test_token_list_pagination(testclient, logged_admin, client):
token_id = res.pyquery(".tokens tbody tr td:nth-of-type(1) a").text()
assert token_id

form = res.forms["next"]
form["page"] = 2
res = form.submit()
form = res.forms["tableform"]
res = form.submit(name="form", value="2")
assert token_id not in res.pyquery(
".tokens tbody tr:nth-of-type(1) td:nth-of-type(1) a"
).text().split(" ")
Expand All @@ -58,15 +57,15 @@ def test_token_list_pagination(testclient, logged_admin, client):

def test_token_list_bad_pages(testclient, logged_admin):
res = testclient.get("/admin/token")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/admin/token",
{"csrf_token": form["csrf_token"].value, "page": "2"},
status=404,
)

res = testclient.get("/admin/token")
form = res.forms["next"]
form = res.forms["tableform"]
testclient.post(
"/admin/token",
{"csrf_token": form["csrf_token"].value, "page": "-1"},
Expand Down

0 comments on commit 8be771e

Please sign in to comment.