Skip to content
Snippets Groups Projects
Commit 73145fe7 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Some first protocol unit tests

parent fda32066
No related branches found
No related tags found
No related merge requests found
...@@ -477,7 +477,6 @@ def show_protocol(protocol): ...@@ -477,7 +477,6 @@ def show_protocol(protocol):
document_upload_form = DocumentUploadForm() document_upload_form = DocumentUploadForm()
source_upload_form = KnownProtocolSourceUploadForm() source_upload_form = KnownProtocolSourceUploadForm()
time_diff = protocol.date - datetime.now().date() time_diff = protocol.date - datetime.now().date()
print(time_diff)
large_time_diff = not protocol.is_done() and time_diff.days > 0 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) 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)
......
...@@ -105,6 +105,20 @@ class FullDBAnonymousTestCase(GeneralTestCase): ...@@ -105,6 +105,20 @@ class FullDBAnonymousTestCase(GeneralTestCase):
assert self.app.get(new_meta_route).status_code == STATUS_REDIRECT assert self.app.get(new_meta_route).status_code == STATUS_REDIRECT
assert self.app.post(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__": if __name__ == "__main__":
unittest.main() unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment