Skip to content

Commit

Permalink
refactor URL test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfermigier committed Jul 9, 2018
1 parent 35d978b commit f5bba78
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions abilian/services/vocabularies/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import sqlalchemy as sa
import sqlalchemy.exc
from hyperlink import URL
from pytest import mark, raises

from abilian.web import url_for
Expand Down Expand Up @@ -136,35 +137,36 @@ def test_admin_panel_reorder(app, db, session, client, test_request_context):
data.update(base_data)
r = client.post(url, data=data)
assert r.status_code == 302
assert r.headers["Location"] == "http://localhost/admin/vocabularies"
assert URL.from_text(r.headers["Location"]).path == "/admin/vocabularies"
assert Voc.query.order_by(Voc.position).all() == [second, first, third]

data = {"up": first.id, "return_to": "group"}
data.update(base_data)
r = client.post(url, data=data)
assert r.status_code == 302
assert r.headers["Location"] == "http://localhost/admin/vocabularies/_/"
assert URL.from_text(r.headers["Location"]).path == "/admin/vocabularies/_/"
assert Voc.query.order_by(Voc.position).all() == [first, second, third]

data = {"up": first.id, "return_to": "model"}
data.update(base_data)
r = client.post(url, data=data)
assert r.status_code == 302
assert (
r.headers["Location"] == "http://localhost/admin/vocabularies/_/defaultstates/"
URL.from_text(r.headers["Location"]).path
== "/admin/vocabularies/_/defaultstates/"
)
assert Voc.query.order_by(Voc.position).all() == [first, second, third]

data = {"down": third.id}
data.update(base_data)
r = client.post(url, data=data)
assert r.status_code == 302
assert r.headers["Location"] == "http://localhost/admin/vocabularies"
assert URL.from_text(r.headers["Location"]).path == "/admin/vocabularies"
assert Voc.query.order_by(Voc.position).all() == [first, second, third]

data = {"up": third.id}
data.update(base_data)
r = client.post(url, data=data)
assert r.status_code == 302
assert r.headers["Location"] == "http://localhost/admin/vocabularies"
assert URL.from_text(r.headers["Location"]).path == "/admin/vocabularies"
assert Voc.query.order_by(Voc.position).all() == [first, third, second]

0 comments on commit f5bba78

Please sign in to comment.