Commit 73145fe7 authored by Robin Sonnabend's avatar Robin Sonnabend

Some first protocol unit tests

parent fda32066
......@@ -477,7 +477,6 @@ def show_protocol(protocol):
document_upload_form = DocumentUploadForm()
source_upload_form = KnownProtocolSourceUploadForm()
time_diff = protocol.date - datetime.now().date()
print(time_diff)
large_time_diff = not protocol.is_done() and time_diff.days > 0
return render_template("protocol-show.html", protocol=protocol, errors_table=errors_table, documents_table=documents_table, document_upload_form=document_upload_form, source_upload_form=source_upload_form, time_diff=time_diff, large_time_diff=large_time_diff)
......
......@@ -104,6 +104,20 @@ class FullDBAnonymousTestCase(GeneralTestCase):
new_meta_route = "/defaultmeta/new/{}".format(protocoltype.id)
assert self.app.get(new_meta_route).status_code == STATUS_REDIRECT
assert self.app.post(new_meta_route).status_code == STATUS_REDIRECT
def test_protocols(self):
with proto3.app.app_context():
new_route = "/protocol/new"
assert self.app.get(new_route).status_code == STATUS_REDIRECT
assert self.app.post(new_route).status_code == STATUS_REDIRECT
protocols = Protocol.query.all()
for protocol in protocols:
visible = protocol.protocoltype.has_public_view_right(None, check_networks=False)
state_ok_or_redirect = STATUS_OK if visible else STATUS_REDIRECT
show_route = "/protocol/show/{}".format(protocol.id)
assert self.app.get(show_route).status_code == state_ok_or_redirect
assert self.app.post(show_route).status_code == STATUS_METHOD
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment