Projet

Général

Profil

0001-misc-move-workflows-tests-for-splitting.patch

Lauréline Guérin, 09 septembre 2021 15:02

Télécharger (7,69 ko)

Voir les différences:

Subject: [PATCH 1/3] misc: move workflows tests for splitting

 tests/workflow/__init__.py                    |  0
 .../test_all.py}                              | 30 +++++++++----------
 2 files changed, 15 insertions(+), 15 deletions(-)
 create mode 100644 tests/workflow/__init__.py
 rename tests/{test_workflows.py => workflow/test_all.py} (99%)
tests/test_workflows.py → tests/workflow/test_all.py
88 88
    perform_items,
89 89
)
90 90

  
91
from .utilities import MockSubstitutionVariables, clean_temporary_pub, create_temporary_pub
91
from ..utilities import MockSubstitutionVariables, clean_temporary_pub, create_temporary_pub
92 92

  
93 93

  
94 94
def setup_module(module):
......
1225 1225
    wf.store()
1226 1226

  
1227 1227
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
1228
    with open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb') as fd:
1228
    with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd:
1229 1229
        upload.receive([fd.read()])
1230 1230

  
1231 1231
    formdef = FormDef()
......
1754 1754
    formdef.store()
1755 1755

  
1756 1756
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
1757
    with open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb') as fd:
1757
    with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd:
1758 1758
        upload.receive([fd.read()])
1759 1759
    formdata = formdef.data_class()()
1760 1760
    formdata.data = {'3': upload}
......
3633 3633
    formdef.store()
3634 3634

  
3635 3635
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
3636
    with open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb') as fd:
3636
    with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd:
3637 3637
        upload.receive([fd.read()])
3638 3638

  
3639 3639
    formdata = formdef.data_class()()
......
3664 3664

  
3665 3665
    # invalid photo
3666 3666
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
3667
    with open(os.path.join(os.path.dirname(__file__), 'template.odt'), 'rb') as fd:
3667
    with open(os.path.join(os.path.dirname(__file__), '..', 'template.odt'), 'rb') as fd:
3668 3668
        upload.receive([fd.read()])
3669 3669
    formdata.data = {'3': upload}
3670 3670
    formdata.geolocations = None
......
3753 3753

  
3754 3754
@pytest.mark.skipif(transform_to_pdf is None, reason='libreoffice not found')
3755 3755
def test_transform_to_pdf():
3756
    with open(os.path.join(os.path.dirname(__file__), 'template.odt'), 'rb') as instream:
3756
    with open(os.path.join(os.path.dirname(__file__), '..', 'template.odt'), 'rb') as instream:
3757 3757
        outstream = transform_to_pdf(instream)
3758 3758
        assert outstream is not False
3759 3759
        assert outstream.read(10).startswith(b'%PDF-')
......
3771 3771
    formdef.store()
3772 3772

  
3773 3773
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
3774
    with open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb') as fd:
3774
    with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd:
3775 3775
        image_data = fd.read()
3776 3776
    upload.receive([image_data])
3777 3777

  
......
3784 3784
    item = ExportToModel()
3785 3785
    item.convert_to_pdf = False
3786 3786
    item.method = 'non-interactive'
3787
    template_filename = os.path.join(os.path.dirname(__file__), template_name)
3787
    template_filename = os.path.join(os.path.dirname(__file__), '..', template_name)
3788 3788
    with open(template_filename, 'rb') as fd:
3789 3789
        template = fd.read()
3790 3790
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
......
3843 3843
    item = ExportToModel()
3844 3844
    item.convert_to_pdf = False
3845 3845
    item.method = 'non-interactive'
3846
    template_filename = os.path.join(os.path.dirname(__file__), 'template-with-qrcode.odt')
3846
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template-with-qrcode.odt')
3847 3847
    with open(template_filename, 'rb') as fd:
3848 3848
        template = fd.read()
3849 3849
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
......
3893 3893
    item = ExportToModel()
3894 3894
    item.method = 'non-interactive'
3895 3895
    item.convert_to_pdf = False
3896
    template_filename = os.path.join(os.path.dirname(__file__), 'template.odt')
3896
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template.odt')
3897 3897
    with open(template_filename, 'rb') as fd:
3898 3898
        template = fd.read()
3899 3899
    upload = QuixoteUpload('/foo/template.odt', content_type='application/octet-stream')
......
3952 3952
    item = ExportToModel()
3953 3953
    item.method = 'non-interactive'
3954 3954
    item.attach_to_history = True
3955
    template_filename = os.path.join(os.path.dirname(__file__), 'template-django.odt')
3955
    template_filename = os.path.join(os.path.dirname(__file__), '..', 'template-django.odt')
3956 3956
    with open(template_filename, 'rb') as fd:
3957 3957
        template = fd.read()
3958 3958
    upload = QuixoteUpload('/foo/template-django.odt', content_type='application/octet-stream')
......
4024 4024
    formdef.store()
4025 4025
    formdef.data_class().wipe()
4026 4026
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
4027
    with open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb') as fd:
4027
    with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd:
4028 4028
        upload.receive([fd.read()])
4029 4029
    formdata = formdef.data_class()()
4030 4030
    formdata.data = {
......
4050 4050
    item = ExportToModel()
4051 4051
    item.method = 'non-interactive'
4052 4052
    item.attach_to_history = True
4053
    template_filename = os.path.join(os.path.dirname(__file__), filename)
4053
    template_filename = os.path.join(os.path.dirname(__file__), '..', filename)
4054 4054
    with open(template_filename, 'rb') as fd:
4055 4055
        template = fd.read()
4056 4056
    upload = QuixoteUpload(filename, content_type='application/octet-stream')
......
4754 4754

  
4755 4755
    # store a PiclableUpload
4756 4756
    upload = PicklableUpload('test.jpeg', 'image/jpeg')
4757
    with open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb') as fd:
4757
    with open(os.path.join(os.path.dirname(__file__), '..', 'image-with-gps-data.jpeg'), 'rb') as fd:
4758 4758
        image_with_gps_data = fd.read()
4759 4759
    upload.receive([image_with_gps_data])
4760 4760

  
......
4895 4895
    assert not Image or formdata.data['bo1'].get_content().find(b'<exif:XResolution>') == -1
4896 4896

  
4897 4897
    upload2 = PicklableUpload('test2.odt', 'application/vnd.oasis.opendocument.text')
4898
    with open(os.path.join(os.path.dirname(__file__), 'template.odt'), 'rb') as fd:
4898
    with open(os.path.join(os.path.dirname(__file__), '..', 'template.odt'), 'rb') as fd:
4899 4899
        template_odt = fd.read()
4900 4900
    upload2.receive([template_odt])
4901 4901
    formdata = formdef.data_class()()
4902
-