Browse Source

completed functional tests for orders

funding-tag
Holger Frey 5 years ago
parent
commit
ef3dd902c0
  1. 2
      ordr3/static/style.css
  2. 9
      ordr3/views/orders.py
  3. 9
      tests/functional/conftest.py
  4. 141
      tests/functional/test_a_order.py
  5. 438
      tests/functional/test_order.py
  6. 251
      tests/functional/test_order_list.py
  7. 60
      tests/functional/test_registration.py
  8. 11
      tests/functional/test_user_edit.py

2
ordr3/static/style.css

@ -144,7 +144,7 @@ td.o3-actions a:hover { @@ -144,7 +144,7 @@ td.o3-actions a:hover {
display:none;
}
.o3-data-table .badge {
.o3-data-table .badge, .o3-log-table .badge {
text-transform: uppercase;
}

9
ordr3/views/orders.py

@ -151,8 +151,8 @@ def order_list(context, request): @@ -151,8 +151,8 @@ def order_list(context, request):
renderer="ordr3:templates/orders/batch_delete.jinja2",
)
def batch_delete(context, request):
subnmitted_orders = get_multiple_orders(context, request)
orders = [o for o in subnmitted_orders if not o.in_process]
submitted_orders = get_multiple_orders(context, request)
orders = [o for o in submitted_orders if not o.in_process]
if not orders:
return HTTPFound(request.resource_url(context))
@ -181,7 +181,8 @@ def batch_delete_confirmed(context, request): @@ -181,7 +181,8 @@ def batch_delete_confirmed(context, request):
if request.POST.get("confirmation", "") != "confirmed":
return HTTPFound(request.resource_url(context.__parent__))
orders = get_multiple_orders(context, request)
submitted_orders = get_multiple_orders(context, request)
orders = [o for o in submitted_orders if not o.in_process]
if not orders:
return HTTPFound(request.resource_url(context))
@ -245,8 +246,6 @@ def batch_edit_confirm(context, request): @@ -245,8 +246,6 @@ def batch_edit_confirm(context, request):
return HTTPFound(request.resource_url(context.__parent__))
orders = get_multiple_orders(context, request)
print(request.POST)
print(orders)
if not orders:
return HTTPFound(request.resource_url(context))

9
tests/functional/conftest.py

@ -224,3 +224,12 @@ def parse_latest_mail(testapp): @@ -224,3 +224,12 @@ def parse_latest_mail(testapp):
return ParsedMail(body, link)
yield _parse_mail
@pytest.fixture
def contains(testapp):
def _contains(response, **what):
result = [(key in response) == value for key, value in what.items()]
return all(result)
yield _contains

141
tests/functional/test_a_order.py

@ -1,141 +0,0 @@ @@ -1,141 +0,0 @@
def test_add_order(testapp, login_as):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" in response
assert "Aceton" not in response
response = testapp.get("/orders/add/")
form = response.forms[1]
form["cas_description"] = "Aceton"
form["category"] = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
form.submit("Place_Order")
response = testapp.get("/orders/")
assert "My Orders" in response
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" in response
assert "Aceton" in response
response = testapp.get("/orders/5/view/")
assert "Aceton" in response
assert "Solvent" in response
assert "567" in response
assert "Carl Roth" in response
assert "25 l" in response
assert "DFG" in response
assert "Ein Kommentar!" in response
assert "5.67" in response
assert "28.35" in response
def test_view_order(testapp, login_as):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.get("/orders/3/view/")
assert "Eppis" in response
assert "345" in response
assert "VWR" in response
assert "Biolab" in response
assert "3 St" in response
assert "34.50" in response
assert "3" in response
assert "USD" in response
assert "103.50" in response
assert "Toto" in response
assert "auf der Seite" in response
assert 'href="http://www.example.com/foo"' in response
assert ">http://www.example.com/foo</a>" in response
assert "open" in response
assert "completed" in response
assert "TestAdmin" in response
assert "TestUser" in response
def test_edit_order_ok(testapp, login_as):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.get("/orders/3/edit/")
form = response.forms[1]
form["cas_description"] = "Aceton"
form["category"] = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
form.submit("Save_Changes")
response = testapp.get("/orders/")
assert "My Orders" in response
assert "Eppis" not in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" in response
assert "Aceton" in response
response = testapp.get("/orders/3/view/")
assert "Aceton" in response
assert "Solvent" in response
assert "567" in response
assert "Carl Roth" in response
assert "25 l" in response
assert "DFG" in response
assert "Ein Kommentar!" in response
assert "5.67" in response
assert "28.35" in response
def test_delete_order(testapp, login_as):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "/orders/4/edit" in response
response = testapp.get("/orders/4/delete")
form = response.forms[1]
form["confirmation"].checked = True
form.submit("delete")
response = testapp.get("/orders/")
assert "has been deleted" in response
assert "My Orders" in response
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "/orders/4/edit" not in response

438
tests/functional/test_order.py

@ -0,0 +1,438 @@ @@ -0,0 +1,438 @@
def test_view_order(testapp, login_as):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.get("/orders/3/view/")
assert "Eppis" in response
assert "345" in response
assert "VWR" in response
assert "Biolab" in response
assert "3 St" in response
assert "34.50" in response
assert "3" in response
assert "USD" in response
assert "103.50" in response
assert "Toto" in response
assert "auf der Seite" in response
assert 'href="http://www.example.com/foo"' in response
assert ">http://www.example.com/foo</a>" in response
assert "open" in response
assert "completed" in response
assert "TestAdmin" in response
assert "TestUser" in response
def test_add_order_ok(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
response = testapp.get("/orders/add/")
form = response.forms[1]
form["cas_description"] = "Aceton"
form["category"] = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
form.submit("Place_Order")
response = testapp.get("/orders/")
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=True,
)
response = testapp.get("/orders/5/view/")
assert "Aceton" in response
assert "Solvent" in response
assert "567" in response
assert "Carl Roth" in response
assert "25 l" in response
assert "DFG" in response
assert "Ein Kommentar!" in response
assert "5.67" in response
assert "28.35" in response
def test_add_order_validation_error(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
response = testapp.get("/orders/add/")
form = response.forms[1]
response = form.submit("Place_Order")
assert "There was a problem with your submission" in response
response = testapp.get("/orders/")
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
def test_add_order_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
response = testapp.get("/orders/add/")
form = response.forms[1]
form["cas_description"] = "Aceton"
form["category"] = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
form.submit("cancel")
response = testapp.get("/orders/")
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
def test_edit_order_ok(testapp, login_as, contains, parse_latest_mail):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
response = testapp.get("/orders/3/edit/")
form = response.forms[1]
form["cas_description"] = "Aceton"
form["status"].value = "HOLD"
form["category"].value = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
form.submit("Save_Changes")
response = testapp.get("/orders/")
assert "My Orders" in response
assert contains(
response,
Eppis=False,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=True,
)
response = testapp.get("/orders/3/view/")
assert "Aceton" in response
assert "hold" in response
assert "Solvent" in response
assert "567" in response
assert "Carl Roth" in response
assert "25 l" in response
assert "DFG" in response
assert "Ein Kommentar!" in response
assert "5.67" in response
assert "28.35" in response
parsed = parse_latest_mail()
assert "The status of one or more of your orders" in parsed.body
assert "Aceton" in parsed.body
assert "- new status: Hold" in parsed.body
def test_edit_order_form_error(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.get("/orders/3/edit/")
form = response.forms[1]
form["cas_description"] = ""
form["category"] = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
response = form.submit("Save_Changes")
assert "There was a problem with your submission" in response
response = testapp.get("/orders/")
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
def test_edit_order_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.get("/orders/3/edit/")
form = response.forms[1]
form["cas_description"] = "Aceton"
form["category"] = "SOLVENT"
form["catalog_nr"] = "567"
form["vendor"] = "Carl Roth"
form["package_size"] = "25 l"
form["quantity"] = "5"
form["account"] = "DFG"
form["comment"] = "Ein Kommentar!"
form.fields["amount"][0].value = "5.67"
form.fields["amount"][1].value = "5.67"
form.fields["currency"][0].value = "USD"
form.fields["currency"][1].value = "USD"
form.submit("cancel")
response = testapp.get("/orders/")
assert "My Orders" in response
assert contains(
response,
Eppis=True,
Ethanol=True,
NaCl=True,
Spritzen=True,
Aceton=False,
)
def test_delete_order_ok(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(response, Eppis=True, Ethanol=True, NaCl=True)
# don't check for "Spritzen", the term will apear in the flash message
# check for edit link
assert "/orders/4/edit" in response
response = testapp.get("/orders/4/delete")
form = response.forms[1]
form["confirmation"].checked = True
form.submit("delete")
response = testapp.get("/orders/")
assert "has been deleted" in response
assert "My Orders" in response
assert contains(response, Eppis=True, Ethanol=True, NaCl=True)
# don't check for "Spritzen", the term will apear in the flash message
# check for edit link
assert "/orders/4/edit" not in response
def test_delete_order_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(response, Eppis=True, Ethanol=True, NaCl=True)
# don't check for "Spritzen", the term will apear in the flash message
# check for edit link
assert "/orders/4/edit" in response
response = testapp.get("/orders/4/delete")
form = response.forms[1]
form["confirmation"].checked = True
form.submit("cancel")
response = testapp.get("/orders/")
assert "has been deleted" not in response
assert "My Orders" in response
assert contains(response, Eppis=True, Ethanol=True, NaCl=True)
# don't check for "Spritzen", the term will apear in the flash message
# check for edit link
assert "/orders/4/edit" in response
def test_delete_order_no_confirm(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert contains(response, Eppis=True, Ethanol=True, NaCl=True)
# don't check for "Spritzen", the term will apear in the flash message
# check for edit link
assert "/orders/4/edit" in response
response = testapp.get("/orders/4/delete")
form = response.forms[1]
form["confirmation"].checked = False
form.submit("delete")
response = testapp.get("/orders/")
assert "has been deleted" not in response
assert "My Orders" in response
assert contains(response, Eppis=True, Ethanol=True, NaCl=True)
# don't check for "Spritzen", the term will apear in the flash message
# check for edit link
assert "/orders/4/edit" in response
def test_reorder_ok(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert "1138,50" not in response
assert "/orders/5/edit" not in response
response = testapp.get("/orders/3/reorder/")
form = response.forms[1]
form["quantity"] = "33"
form.submit("Place_Order")
response = testapp.get("/orders/")
assert "has been placed." in response
assert "1138,50" in response
assert "/orders/5/edit" in response
response = testapp.get("/orders?status=open", status=200)
assert contains(
response, Eppis=True, Ethanol=False, NaCl=False, Spritzen=True
)
response = testapp.get("/orders?status=completed", status=200)
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
def test_reorder_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert "1138,50" not in response
assert "/orders/5/edit" not in response
response = testapp.get("/orders/3/reorder/")
form = response.forms[1]
form["quantity"] = "33"
form.submit("cancel")
response = testapp.get("/orders/")
assert "has been placed." not in response
assert "1138,50" not in response
assert "/orders/5/edit" not in response
response = testapp.get("/orders?status=open", status=200)
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
def test_reorder_form_error(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert "1138,50" not in response
assert "/orders/5/edit" not in response
response = testapp.get("/orders/3/reorder/")
form = response.forms[1]
form["quantity"] = ""
response = form.submit("Place_Order")
assert "There was a problem with your submission" in response
response = testapp.get("/orders?status=open", status=200)
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)

251
tests/functional/test_order_list.py

@ -1,56 +1,110 @@ @@ -1,56 +1,110 @@
def test_order_list(testapp, login_as):
def test_order_list(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
response = testapp.get("/orders?status=completed", status=200)
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" not in response
assert "Spritzen" not in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=False, Spritzen=False
)
response = testapp.get("/orders?user=TestAdmin", status=200)
assert "Eppis" not in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" not in response
assert contains(
response, Eppis=False, Ethanol=True, NaCl=True, Spritzen=False
)
response = testapp.get(
"/orders?user=TestAdmin&status=completed", status=200
)
assert "Eppis" not in response
assert "Ethanol" in response
assert "NaCl" not in response
assert "Spritzen" not in response
assert contains(
response, Eppis=False, Ethanol=True, NaCl=False, Spritzen=False
)
response = testapp.get(
"/orders?user=TestAdmin&status=approval", status=200
)
assert "Eppis" not in response
assert "Ethanol" not in response
assert "NaCl" in response
assert "Spritzen" not in response
assert contains(
response, Eppis=False, Ethanol=False, NaCl=True, Spritzen=False
)
response = testapp.get("/orders?user=-purchaser-", status=200)
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" not in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=False
)
response = testapp.get("/orders?search=vwr", status=200)
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" not in response
assert "Spritzen" not in response
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
)
def test_multi_edit_ok(testapp, login_as):
def test_multi_edit_ok(testapp, login_as, parse_latest_mail, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
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
def test_multi_edit_no_orders_selected(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
form = response.forms[1]
form.action = "/orders/batch-edit/"
response = form.submit().follow(status=200)
assert "My Orders" in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
def test_multi_edit_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
@ -64,37 +118,33 @@ def test_multi_edit_ok(testapp, login_as): @@ -64,37 +118,33 @@ def test_multi_edit_ok(testapp, login_as):
select_checkboxes[1].checked = True
response = form.submit()
assert "Eppis" not in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" not in response
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("change")
form.submit("cancel")
response = testapp.get("/orders?status=completed", status=200)
assert "orders have been updated." in response
assert "Eppis" in response
assert "Ethanol" not in response
assert "NaCl" not in response
assert "Spritzen" not in response
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 "Eppis" not in response
assert "Ethanol" not in response
assert "NaCl" not in response
assert "Spritzen" in response
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
response = testapp.get("/orders?status=hold", status=200)
assert "Eppis" not in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" not in response
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=False
)
def test_multi_delete_ok(testapp, login_as):
def test_multi_delete_ok(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
@ -108,10 +158,9 @@ def test_multi_delete_ok(testapp, login_as): @@ -108,10 +158,9 @@ def test_multi_delete_ok(testapp, login_as):
select_checkboxes[3].checked = True
response = form.submit()
assert "Eppis" not in response
assert "Ethanol" not in response
assert "NaCl" not in response
assert "Spritzen" in response
assert contains(
response, Eppis=False, Ethanol=False, NaCl=False, Spritzen=True
)
form = response.forms[1]
form["confirmation"].checked = True
@ -119,7 +168,95 @@ def test_multi_delete_ok(testapp, login_as): @@ -119,7 +168,95 @@ def test_multi_delete_ok(testapp, login_as):
response = testapp.get("/orders", status=200)
assert "orders have been deleted." in response
assert "Eppis" in response
assert "Ethanol" in response
assert "NaCl" in response
assert "Spritzen" not in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=False
)
def test_multi_delete_no_orders(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
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(status=200)
assert "My Orders" in response
assert contains(
response, Eppis=True, Ethanol=True, NaCl=True, Spritzen=True
)
def test_multi_delete_no_confirm(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
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
)
def test_multi_delete_cancel(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
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
)
def test_check_vendor_name(testapp, login_as, contains):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.post("/orders/vendor", {"vendor": "test"}, xhr=True)
assert '{"name": "test", "found": false}' in response

60
tests/functional/test_registration.py

@ -57,6 +57,66 @@ def test_registration_procedure_form_error( @@ -57,6 +57,66 @@ def test_registration_procedure_form_error(
assert "There was a problem with your submission" in response
def test_registration_procedure_not_unique_username(
testapp, login_as, parse_latest_mail
):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["user_name"] = "TestAdmin"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "eric@example.com"
form["password"] = "eric"
response = form.submit("Create_Account")
assert "There was a problem with your submission" in response
def test_registration_procedure_not_unique_email(
testapp, login_as, parse_latest_mail
):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["user_name"] = "TestNew"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "jane@example.com"
form["password"] = "eric"
response = form.submit("Create_Account")
assert "There was a problem with your submission" in response
def test_registration_procedure_bad_csrf_token(
testapp, login_as, parse_latest_mail
):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = testapp.get("/registration", status=200)
assert "Register a new account" in response
form = response.form
form["csrf_token"] = "bad token"
form["user_name"] = "TestNew"
form["first_name"] = "Eric"
form["last_name"] = "Idle"
form["email"] = "eric@example.com"
form["password"] = "eric"
form.submit("Create_Account", status=400)
def test_registration_procedure_canceled(testapp, login_as, parse_latest_mail):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response

11
tests/functional/test_user_edit.py

@ -58,6 +58,17 @@ def test_user_edit_form_error(testapp, login_as): @@ -58,6 +58,17 @@ def test_user_edit_form_error(testapp, login_as):
assert "There was a problem with your submission" in response
def test_user_edit_invalid_user(testapp, login_as):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response
response = login_as("TestAdmin", "jane").follow(status=200)
assert "My Orders" in response
response = testapp.get("/users/Unknown/edit").follow()
assert "My Orders" in response
def test_user_edit_reset_password(testapp, login_as, parse_latest_mail):
response = testapp.get("/", status=302).follow(status=200)
assert "Please Log In" in response

Loading…
Cancel
Save