From 33cc0a5ad62fa4167b04825c9033cc281de16f7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Fri, 23 Oct 2020 09:05:41 +0200
Subject: [PATCH 1/5] misc: move form pages test module

---
 tests/form_pages/__init__.py                  |  0
 .../test_all.py}                              | 32 +++++++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)
 create mode 100644 tests/form_pages/__init__.py
 rename tests/{test_form_pages.py => form_pages/test_all.py} (99%)

diff --git a/tests/form_pages/__init__.py b/tests/form_pages/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/test_form_pages.py b/tests/form_pages/test_all.py
similarity index 99%
rename from tests/test_form_pages.py
rename to tests/form_pages/test_all.py
index 0fde1fab..23a1283f 100644
--- a/tests/test_form_pages.py
+++ b/tests/form_pages/test_all.py
@@ -3171,7 +3171,7 @@ def test_form_file_field_image_submit(pub):
     formdef.store()
     formdef.data_class().wipe()
 
-    image_content = open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb').read()
+    image_content = open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb').read()
     upload = Upload('test.jpg', image_content, 'image/jpeg')
 
     app = get_app(pub)
@@ -3227,7 +3227,7 @@ def test_form_file_field_submit_document_type(pub):
     resp = resp.form.submit('submit')
     assert 'invalid file type' in resp.text
 
-    image_content = open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb').read()
+    image_content = open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb').read()
     upload = Upload('test.jpg', image_content, 'image/jpeg')
     resp = get_app(pub).get('/test/')
     resp.form['f0$file'] = upload
@@ -3862,7 +3862,7 @@ def test_formdata_generated_document_odt_download(pub, odt_template):
     export_to = ExportToModel()
     export_to.convert_to_pdf = False
     export_to.label = 'create doc'
-    template_filename = os.path.join(os.path.dirname(__file__), odt_template)
+    template_filename = os.path.join(os.path.dirname(__file__), '..', odt_template)
     template = open(template_filename, 'rb').read()
     upload = QuixoteUpload('/foo/' + odt_template, content_type='application/octet-stream')
     upload.fp = BytesIO()
@@ -3895,7 +3895,7 @@ def test_formdata_generated_document_odt_download(pub, odt_template):
 
     resp = resp.follow() # $form/$id/create_doc
     resp = resp.follow() # $form/$id/create_doc/
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         assert_equal_zip(BytesIO(resp.body), f)
 
     resp = login(get_app(pub), username='foo', password='foo').get(form_location)
@@ -3922,7 +3922,7 @@ def test_formdata_generated_document_odt_download(pub, odt_template):
     assert resp.location.endswith('/' + odt_template)
     resp = resp.follow()
     assert resp.content_type == 'application/octet-stream'
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         assert_equal_zip(BytesIO(resp.body), f)
 
     # change file content, same name
@@ -3938,7 +3938,7 @@ def test_formdata_generated_document_odt_download(pub, odt_template):
     assert resp.location == form_location + '#action-zone'
     resp = resp.follow() # back to form page
 
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         body = resp.click(odt_template, index=0).follow().body
         assert_equal_zip(BytesIO(body), f)
     assert resp.click('test.rtf', index=0).follow().body == b'HELLO NEW WORLD'
@@ -3952,7 +3952,7 @@ def test_formdata_generated_document_odt_download_with_substitution_variable(pub
     export_to.convert_to_pdf = False
     export_to.label = 'create doc'
     export_to.varname = 'created_doc'
-    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
+    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
     template = open(template_filename, 'rb').read()
     upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
     upload.fp = BytesIO()
@@ -3985,7 +3985,7 @@ def test_formdata_generated_document_odt_download_with_substitution_variable(pub
 
     resp = resp.follow() # $form/$id/create_doc
     resp = resp.follow() # $form/$id/create_doc/
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         assert_equal_zip(BytesIO(resp.body), f)
 
     export_to.attach_to_history = True
@@ -4000,7 +4000,7 @@ def test_formdata_generated_document_odt_download_with_substitution_variable(pub
     assert resp.location.endswith('/template.odt')
     response1 = resp = resp.follow()
     assert resp.content_type == 'application/octet-stream'
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         assert_equal_zip(BytesIO(resp.body), f)
 
     # change file content, same name
@@ -4016,7 +4016,7 @@ def test_formdata_generated_document_odt_download_with_substitution_variable(pub
     assert resp.location == form_location + '#action-zone'
     resp = resp.follow() # back to form page
 
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         body = resp.click('template.odt', index=0).follow().body
         assert_equal_zip(BytesIO(body), f)
     response2 = resp.click('test.rtf', index=0).follow()
@@ -4071,7 +4071,7 @@ def test_formdata_generated_document_odt_to_pdf_download(pub):
     export_to = ExportToModel()
     export_to.label = 'create doc'
     export_to.varname = 'created_doc'
-    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
+    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
     template = open(template_filename, 'rb').read()
     upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
     upload.fp = BytesIO()
@@ -4139,7 +4139,7 @@ def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(pub,
     export_to = ExportToModel()
     export_to.label = 'create doc'
     export_to.varname = 'created_doc'
-    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
+    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
     template = open(template_filename, 'rb').read()
     upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
     upload.fp = BytesIO()
@@ -4230,7 +4230,7 @@ def test_formdata_generated_document_non_interactive(pub):
     export_to = ExportToModel()
     export_to.convert_to_pdf = False
     export_to.method = 'non-interactive'
-    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
+    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
     template = open(template_filename, 'rb').read()
     upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
     upload.fp = BytesIO()
@@ -4271,7 +4271,7 @@ def test_formdata_generated_document_non_interactive(pub):
     assert resp.location.endswith('/template.odt')
     resp = resp.follow()
     assert resp.content_type == 'application/octet-stream'
-    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
         assert_equal_zip(BytesIO(resp.body), f)
 
     assert formdef.data_class().count() == 1
@@ -4291,7 +4291,7 @@ def test_formdata_generated_document_to_backoffice_field(pub):
     export_to = ExportToModel()
     export_to.convert_to_pdf = False
     export_to.method = 'non-interactive'
-    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
+    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
     template = open(template_filename, 'rb').read()
     upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
     upload.fp = BytesIO()
@@ -4337,7 +4337,7 @@ def test_formdata_generated_document_to_backoffice_field(pub):
         assert resp.location.endswith('/template.odt')
         resp = resp.follow()
         assert resp.content_type == 'application/octet-stream'
-        with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
+        with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
             assert_equal_zip(BytesIO(resp.body), f)
 
     assert formdef.data_class().count() == 1
-- 
2.28.0

