Projet

Général

Profil

0001-test-do-fulltext-indexation-on-item-s-field-display-.patch

Nicolas Roche, 17 mai 2021 16:16

Télécharger (1,96 ko)

Voir les différences:

Subject: [PATCH 1/2] test: do fulltext indexation on item(s) field display
 value (#53284)

 tests/test_sql.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tests/test_sql.py
114 114
    assert data_class.get('xxx', ignore_errors=True) is None
115 115
    assert data_class.get(None, ignore_errors=True) is None
116 116

  
117 117

  
118 118
def check_sql_field(no, value):
119 119
    data_class = formdef.data_class(mode='sql')
120 120
    formdata = data_class()
121 121
    formdata.data = {no: value}
122

  
123
    field = formdef.fields[int(no)]
124
    if field.key in ('item', 'items'):
125
        formdata.data['%s_display' % no] = field.store_display_value(formdata.data, no)
122 126
    formdata.store()
123 127
    id = formdata.id
124 128

  
125 129
    formdata = data_class.get(id)
126 130
    assert formdata.data.get(no) == value
131
    if field.key == 'item':
132
        assert formdata.data['%s_display' % no] == value
133
    elif field.key == 'items':
134
        assert formdata.data['%s_display' % no] == ', '.join(value)
127 135

  
128 136

  
129 137
def test_sql_field_string():
130 138
    check_sql_field('0', 'hello world')
131 139
    check_sql_field('0', 'élo world')
132 140
    check_sql_field('0', None)
133 141

  
134 142

  
......
152 160

  
153 161
def test_sql_field_date():
154 162
    check_sql_field('5', datetime.date.today().timetuple())
155 163

  
156 164

  
157 165
def test_sql_field_items():
158 166
    check_sql_field('6', ['apricot'])
159 167
    check_sql_field('6', ['apricot', 'pear'])
160
    check_sql_field('6', ['pomme', 'poire', 'pêche'])
168
    check_sql_field('6', ['apple', 'pear', 'peach'])
161 169

  
162 170

  
163 171
def test_sql_geoloc():
164 172
    test_formdef = FormDef()
165 173
    test_formdef.name = 'geoloc'
166 174
    test_formdef.fields = []
167 175
    test_formdef.geolocations = {'base': 'Plop'}
168 176
    test_formdef.store()
169
-