Projet

Général

Profil

0001-sql-honor-ignore_errors-in-get-when-using-numeric-id.patch

Frédéric Péters, 08 décembre 2022 22:09

Télécharger (1,6 ko)

Voir les différences:

Subject: [PATCH] sql: honor ignore_errors in get() when using numeric ids
 (#71492)

 tests/test_snapshots.py | 15 +++++++++++++++
 wcs/sql.py              |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
tests/test_snapshots.py
211 211
    assert str(snapshot.user) == 'unknown user'
212 212

  
213 213

  
214
def test_form_snapshot_404(pub):
215
    create_superuser(pub)
216
    create_role(pub)
217

  
218
    FormDef.wipe()
219
    formdef = FormDef()
220
    formdef.name = 'testform'
221
    formdef.fields = []
222
    formdef.store()
223

  
224
    app = login(get_app(pub))
225
    app.get('/backoffice/forms/%s/history/XXX/view/' % formdef.id, status=404)
226

  
227

  
214 228
def test_form_snapshot_diff(pub):
215 229
    create_superuser(pub)
216 230
    create_role(pub)
217 231

  
232
    FormDef.wipe()
218 233
    formdef = FormDef()
219 234
    formdef.name = 'testform'
220 235
    formdef.fields = []
wcs/sql.py
2162 2162
            try:
2163 2163
                int(id)
2164 2164
            except (TypeError, ValueError):
2165
                if ignore_errors and id is None:
2165
                if ignore_errors and (cls._numerical_id or id is None):
2166 2166
                    return None
2167 2167
                else:
2168 2168
                    raise KeyError()
2169
-