Projet

Général

Profil

0001-misc-move-form-pages-test-module.patch

Lauréline Guérin, 23 octobre 2020 19:12

Télécharger (9,07 ko)

Voir les différences:

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%)
tests/test_form_pages.py → tests/form_pages/test_all.py
3171 3171
    formdef.store()
3172 3172
    formdef.data_class().wipe()
3173 3173

  
3174
    image_content = open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb').read()
3174
    image_content = open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb').read()
3175 3175
    upload = Upload('test.jpg', image_content, 'image/jpeg')
3176 3176

  
3177 3177
    app = get_app(pub)
......
3227 3227
    resp = resp.form.submit('submit')
3228 3228
    assert 'invalid file type' in resp.text
3229 3229

  
3230
    image_content = open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb').read()
3230
    image_content = open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb').read()
3231 3231
    upload = Upload('test.jpg', image_content, 'image/jpeg')
3232 3232
    resp = get_app(pub).get('/test/')
3233 3233
    resp.form['f0$file'] = upload
......
3862 3862
    export_to = ExportToModel()
3863 3863
    export_to.convert_to_pdf = False
3864 3864
    export_to.label = 'create doc'
3865
    template_filename = os.path.join(os.path.dirname(__file__), odt_template)
3865
    template_filename = os.path.join(os.path.dirname(__file__), '..', odt_template)
3866 3866
    template = open(template_filename, 'rb').read()
3867 3867
    upload = QuixoteUpload('/foo/' + odt_template, content_type='application/octet-stream')
3868 3868
    upload.fp = BytesIO()
......
3895 3895

  
3896 3896
    resp = resp.follow() # $form/$id/create_doc
3897 3897
    resp = resp.follow() # $form/$id/create_doc/
3898
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
3898
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
3899 3899
        assert_equal_zip(BytesIO(resp.body), f)
3900 3900

  
3901 3901
    resp = login(get_app(pub), username='foo', password='foo').get(form_location)
......
3922 3922
    assert resp.location.endswith('/' + odt_template)
3923 3923
    resp = resp.follow()
3924 3924
    assert resp.content_type == 'application/octet-stream'
3925
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
3925
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
3926 3926
        assert_equal_zip(BytesIO(resp.body), f)
3927 3927

  
3928 3928
    # change file content, same name
......
3938 3938
    assert resp.location == form_location + '#action-zone'
3939 3939
    resp = resp.follow() # back to form page
3940 3940

  
3941
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
3941
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
3942 3942
        body = resp.click(odt_template, index=0).follow().body
3943 3943
        assert_equal_zip(BytesIO(body), f)
3944 3944
    assert resp.click('test.rtf', index=0).follow().body == b'HELLO NEW WORLD'
......
3952 3952
    export_to.convert_to_pdf = False
3953 3953
    export_to.label = 'create doc'
3954 3954
    export_to.varname = 'created_doc'
3955
    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
3955
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
3956 3956
    template = open(template_filename, 'rb').read()
3957 3957
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
3958 3958
    upload.fp = BytesIO()
......
3985 3985

  
3986 3986
    resp = resp.follow() # $form/$id/create_doc
3987 3987
    resp = resp.follow() # $form/$id/create_doc/
3988
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
3988
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
3989 3989
        assert_equal_zip(BytesIO(resp.body), f)
3990 3990

  
3991 3991
    export_to.attach_to_history = True
......
4000 4000
    assert resp.location.endswith('/template.odt')
4001 4001
    response1 = resp = resp.follow()
4002 4002
    assert resp.content_type == 'application/octet-stream'
4003
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
4003
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
4004 4004
        assert_equal_zip(BytesIO(resp.body), f)
4005 4005

  
4006 4006
    # change file content, same name
......
4016 4016
    assert resp.location == form_location + '#action-zone'
4017 4017
    resp = resp.follow() # back to form page
4018 4018

  
4019
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
4019
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
4020 4020
        body = resp.click('template.odt', index=0).follow().body
4021 4021
        assert_equal_zip(BytesIO(body), f)
4022 4022
    response2 = resp.click('test.rtf', index=0).follow()
......
4071 4071
    export_to = ExportToModel()
4072 4072
    export_to.label = 'create doc'
4073 4073
    export_to.varname = 'created_doc'
4074
    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
4074
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
4075 4075
    template = open(template_filename, 'rb').read()
4076 4076
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
4077 4077
    upload.fp = BytesIO()
......
4139 4139
    export_to = ExportToModel()
4140 4140
    export_to.label = 'create doc'
4141 4141
    export_to.varname = 'created_doc'
4142
    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
4142
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
4143 4143
    template = open(template_filename, 'rb').read()
4144 4144
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
4145 4145
    upload.fp = BytesIO()
......
4230 4230
    export_to = ExportToModel()
4231 4231
    export_to.convert_to_pdf = False
4232 4232
    export_to.method = 'non-interactive'
4233
    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
4233
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
4234 4234
    template = open(template_filename, 'rb').read()
4235 4235
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
4236 4236
    upload.fp = BytesIO()
......
4271 4271
    assert resp.location.endswith('/template.odt')
4272 4272
    resp = resp.follow()
4273 4273
    assert resp.content_type == 'application/octet-stream'
4274
    with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
4274
    with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
4275 4275
        assert_equal_zip(BytesIO(resp.body), f)
4276 4276

  
4277 4277
    assert formdef.data_class().count() == 1
......
4291 4291
    export_to = ExportToModel()
4292 4292
    export_to.convert_to_pdf = False
4293 4293
    export_to.method = 'non-interactive'
4294
    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
4294
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
4295 4295
    template = open(template_filename, 'rb').read()
4296 4296
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
4297 4297
    upload.fp = BytesIO()
......
4337 4337
        assert resp.location.endswith('/template.odt')
4338 4338
        resp = resp.follow()
4339 4339
        assert resp.content_type == 'application/octet-stream'
4340
        with open(os.path.join(os.path.dirname(__file__), 'template-out.odt'), 'rb') as f:
4340
        with open(os.path.join(os.path.dirname(__file__), '..', 'template-out.odt'), 'rb') as f:
4341 4341
            assert_equal_zip(BytesIO(resp.body), f)
4342 4342

  
4343 4343
    assert formdef.data_class().count() == 1
4344
-