Our custom ordering system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

265 lines
7.9 KiB

import pytest
@pytest.mark.functional
def test_order_list(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
response = testapp.get("/orders?status=completed", status=200)
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
response = testapp.get("/orders?category=biolab", status=200)
assert contains(
response, Eppis=True, Ethanol=False, NaCl=False, Spritzen=True
)
response = testapp.get("/orders?user=TestAdmin", status=200)
assert contains(
response, Eppis=False, Ethanol=True, NaCl=True, Spritzen=False
)
response = testapp.get(
"/orders?user=TestAdmin&status=completed", status=200
)
assert contains(
response, Eppis=False, Ethanol=True, NaCl=False, Spritzen=False
)
response = testapp.get("/orders?user=TestAdmin&status=approval", status=200)
assert contains(
response, Eppis=False, Ethanol=False, NaCl=True, Spritzen=False
)
response = testapp.get("/orders?user=-purchaser-", status=200)
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=False
)
response = testapp.get("/orders?search=vwr", status=200)
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
response = testapp.get("/orders?o=1", status=200)
assert contains(
response, Eppis=True, Ethanol=False, NaCl=True, Spritzen=True
)
response = testapp.get("/orders?o=error", status=200)
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
@pytest.mark.functional
def test_multi_edit_ok(testapp, login_as, parse_latest_mail, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-edit/"
select_checkboxes = form.fields["selection"]
select_checkboxes[0].checked = True
select_checkboxes[2].checked = True
response = form.submit()
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
form = response.forms[1]
form["status-1"].value = "HOLD"
form["status-3"].value = "HOLD"
form.submit("change")
response = testapp.get("/orders?status=hold", status=200)
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
parsed = parse_latest_mail()
assert "The status of one or more of your orders" in parsed.body
assert "Eppis" in parsed.body
assert "- new status: Hold" in parsed.body
@pytest.mark.functional
def test_multi_edit_no_orders_selected(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-edit/"
response = form.submit().follow()
assert "My Orders" in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
@pytest.mark.functional
def test_multi_edit_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-edit/"
select_checkboxes = form.fields["selection"]
select_checkboxes[0].checked = True
select_checkboxes[1].checked = True
response = form.submit()
assert contains(
response, Eppis=False, Ethanol=True, NaCl=True, Spritzen=False
)
form = response.forms[1]
form["status-1"].value = "HOLD"
form["status-2"].value = "HOLD"
form.submit("cancel")
response = testapp.get("/orders?status=completed", status=200)
assert "orders have been updated." not in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
response = testapp.get("/orders?status=open", status=200)
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
response = testapp.get("/orders?status=hold", status=200)
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=False
)
@pytest.mark.functional
def test_multi_delete_ok(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-delete/"
select_checkboxes = form.fields["selection"]
select_checkboxes[0].checked = True
select_checkboxes[3].checked = True
response = form.submit()
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
form = response.forms[1]
form["confirmation"].checked = True
form.submit("delete")
response = testapp.get("/orders", status=200)
assert "orders have been deleted." in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=False
)
@pytest.mark.functional
def test_multi_delete_no_orders(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-delete/"
select_checkboxes = form.fields["selection"]
select_checkboxes[0].checked = True
select_checkboxes[1].checked = True
response = form.submit().follow()
assert "My Orders" in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
@pytest.mark.functional
def test_multi_delete_no_confirm(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-delete/"
select_checkboxes = form.fields["selection"]
select_checkboxes[0].checked = True
select_checkboxes[3].checked = True
response = form.submit()
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
form = response.forms[1]
form["confirmation"].checked = False
form.submit("delete")
response = testapp.get("/orders", status=200)
assert "orders have been deleted." not in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
@pytest.mark.functional
def test_multi_delete_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow()
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow()
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-delete/"
select_checkboxes = form.fields["selection"]
select_checkboxes[0].checked = True
select_checkboxes[3].checked = True
response = form.submit()
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
form = response.forms[1]
form["confirmation"].checked = True
form.submit("cancel")
response = testapp.get("/orders", status=200)
assert "orders have been deleted." not in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)