tests: remove usage of string fields (#74653)
gitea/wcs-olap/pipeline/head This commit looks good
Details
gitea/wcs-olap/pipeline/head This commit looks good
Details
This commit is contained in:
parent
559681f3bc
commit
40feb778d6
|
@ -116,16 +116,16 @@ formdef.fields = [
|
|||
display_locations=['statistics']),
|
||||
fields.BoolField(id='3', label='3rd field', type='bool', varname='bool', display_locations=['statistics']),
|
||||
fields.ItemField(id='4', label='4rth field', type='item', varname='itemOpen', display_locations=['statistics']),
|
||||
fields.StringField(id='5', label='5th field', type='string', anonymise=False, varname='stringCaseSensitive-é', display_locations=['statistics']),
|
||||
fields.ItemField(id='5', label='5th field', type='item', anonymise=False, varname='itemCaseSensitive-é', display_locations=['statistics']),
|
||||
fields.BoolField(id='6', label='6th field bad duplicate', type='bool', varname='duplicate', display_locations=['statistics']),
|
||||
fields.StringField(id='7', label='7th field bad duplicate', type='string', anonymise=False, varname='duplicate', display_locations=['statistics']),
|
||||
fields.ItemField(id='7', label='7th field bad duplicate', type='item', anonymise=False, varname='duplicate', display_locations=['statistics']),
|
||||
fields.StringField(id='8', label='8th field integer', type='string', anonymise=False, varname='integer',
|
||||
validation={'type': 'digits'}, display_locations=['statistics']),
|
||||
fields.StringField(id='9', label='9th field good duplicate', type='string', anonymise=False,
|
||||
required=False, varname='good_duplicate', display_locations=['statistics']),
|
||||
fields.StringField(id='10', label='10th field good duplicate', type='string', anonymise=False,
|
||||
required=False, varname='good_duplicate', display_locations=['statistics']),
|
||||
fields.StringField(id='11', label='11th field third bad duplicate', type='string',
|
||||
fields.ItemField(id='9', label='9th field good duplicate', type='item', anonymise=False,
|
||||
required=False, varname='good_duplicate', display_locations=['statistics'], items=['a', 'b']),
|
||||
fields.ItemField(id='10', label='10th field good duplicate', type='item', anonymise=False,
|
||||
required=False, varname='good_duplicate', display_locations=['statistics'], items=['a', 'b']),
|
||||
fields.ItemField(id='11', label='11th field third bad duplicate', type='item',
|
||||
anonymise=False, varname='duplicate', display_locations=['statistics']),
|
||||
fields.BoolField(id='12', label='12th field', type='bool', varname='bool-other-no-stats', display_locations=[]),
|
||||
]
|
||||
|
@ -148,12 +148,14 @@ for i in range(50):
|
|||
formdata.data['4'] = 'open_one'
|
||||
formdata.data['4_display'] = 'open_one'
|
||||
formdata.data['9'] = 'a'
|
||||
formdata.data['9_display'] = 'a'
|
||||
elif i%4 == 1:
|
||||
formdata.data['2'] = 'bar'
|
||||
formdata.data['2_display'] = 'bar'
|
||||
formdata.data['4'] = 'open_two'
|
||||
formdata.data['4_display'] = 'open_two'
|
||||
formdata.data['10'] = 'b'
|
||||
formdata.data['10_display'] = 'b'
|
||||
formdata.data['8'] = str(i)
|
||||
else:
|
||||
formdata.data['2'] = 'baz'
|
||||
|
@ -161,7 +163,9 @@ for i in range(50):
|
|||
formdata.data['4'] = "open'three"
|
||||
formdata.data['4_display'] = "open'three"
|
||||
formdata.data['9'] = 'a'
|
||||
formdata.data['9_display'] = 'a'
|
||||
formdata.data['10'] = 'b'
|
||||
formdata.data['10_display'] = 'b'
|
||||
formdata.data['8'] = '11111111111111111111111'
|
||||
|
||||
formdata.data['3'] = bool(i % 2)
|
||||
|
|
|
@ -244,13 +244,6 @@
|
|||
"value" : "\"function__receiver\".id",
|
||||
"value_label" : "\"function__receiver\".label"
|
||||
},
|
||||
{
|
||||
"filter": true,
|
||||
"label": "1st field",
|
||||
"name": "string",
|
||||
"type": "string",
|
||||
"value": "\"field_string\""
|
||||
},
|
||||
{
|
||||
"filter" : true,
|
||||
"join" : [
|
||||
|
@ -282,18 +275,26 @@
|
|||
"value_label" : "\"join_itemOpen\".label"
|
||||
},
|
||||
{
|
||||
"filter": true,
|
||||
"label": "5th field",
|
||||
"name": "stringCaseSensitive-é",
|
||||
"type": "string",
|
||||
"value": "\"field_stringCaseSensitive-é\""
|
||||
"filter" : true,
|
||||
"join" : [
|
||||
"join_itemCaseSensitive-é"
|
||||
],
|
||||
"label" : "5th field",
|
||||
"name" : "itemCaseSensitive-é",
|
||||
"type" : "integer",
|
||||
"value" : "\"join_itemCaseSensitive-é\".id",
|
||||
"value_label" : "\"join_itemCaseSensitive-é\".label"
|
||||
},
|
||||
{
|
||||
"filter": true,
|
||||
"label": "10th field good duplicate",
|
||||
"name": "good_duplicate",
|
||||
"type": "string",
|
||||
"value": "\"field_good_duplicate\""
|
||||
"filter" : true,
|
||||
"join" : [
|
||||
"join_good_duplicate"
|
||||
],
|
||||
"label" : "10th field good duplicate",
|
||||
"name" : "good_duplicate",
|
||||
"type" : "integer",
|
||||
"value" : "\"join_good_duplicate\".id",
|
||||
"value_label" : "\"join_good_duplicate\".label"
|
||||
}
|
||||
],
|
||||
"fact_table" : "\"formdata_demande\"",
|
||||
|
@ -372,10 +373,24 @@
|
|||
},
|
||||
{
|
||||
"detail" : "id",
|
||||
"kind" : "left",
|
||||
"master" : "\"field_itemOpen\"",
|
||||
"name" : "join_itemOpen",
|
||||
"table" : "\"formdata_demande_field_itemOpen\"",
|
||||
"kind" : "left"
|
||||
"table" : "\"formdata_demande_field_itemOpen\""
|
||||
},
|
||||
{
|
||||
"detail" : "id",
|
||||
"kind" : "left",
|
||||
"master" : "\"field_itemCaseSensitive-é\"",
|
||||
"name" : "join_itemCaseSensitive-é",
|
||||
"table" : "\"formdata_demande_field_itemCaseSensitive-é\""
|
||||
},
|
||||
{
|
||||
"detail" : "id",
|
||||
"kind" : "left",
|
||||
"master" : "\"field_good_duplicate\"",
|
||||
"name" : "join_good_duplicate",
|
||||
"table" : "\"formdata_demande_field_good_duplicate\""
|
||||
}
|
||||
],
|
||||
"key" : "id",
|
||||
|
@ -416,17 +431,11 @@
|
|||
"label" : "localisation géographique",
|
||||
"name" : "geolocation",
|
||||
"type" : "point"
|
||||
},
|
||||
{
|
||||
"name": "sum_integer",
|
||||
"label": "total du champ « 8th field integer »",
|
||||
"type": "integer",
|
||||
"expression": "SUM({fact_table}.\"field_integer\")"
|
||||
}
|
||||
],
|
||||
"name" : "formdata_demande",
|
||||
"warnings": [
|
||||
"Le champ « 7th field bad duplicate » a un nom de variable dupliqué « duplicate » mais pas le même type que « 6th field bad duplicate », tous les champs avec ce nom seront ignorés (string != bool).",
|
||||
"warnings" : [
|
||||
"Le champ « 7th field bad duplicate » a un nom de variable dupliqué « duplicate » mais pas le même type que « 6th field bad duplicate », tous les champs avec ce nom seront ignorés (item != bool).",
|
||||
"Le champ « 11th field third bad duplicate » est un doublon d'un champ de type différent, il a été ignoré."
|
||||
]
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ def test_wcs_fixture(wcs, postgres_db, tmpdir, olap_cmd, caplog):
|
|||
assert (
|
||||
'Le champ « 7th field bad duplicate » a un nom de variable dupliqué '
|
||||
'« duplicate » mais pas le même type que « 6th field bad duplicate », '
|
||||
'tous les champs avec ce nom seront ignorés (string != bool).'
|
||||
'tous les champs avec ce nom seront ignorés (item != bool).'
|
||||
) in caplog.text
|
||||
assert (
|
||||
'Le champ « 11th field third bad duplicate » est un doublon d\'un '
|
||||
|
@ -108,16 +108,18 @@ def test_wcs_fixture(wcs, postgres_db, tmpdir, olap_cmd, caplog):
|
|||
('formdata_demande', 'geolocation_base'),
|
||||
('formdata_demande', 'json_data'),
|
||||
('formdata_demande', 'status_id'),
|
||||
('formdata_demande', 'field_string'),
|
||||
('formdata_demande', 'field_item'),
|
||||
('formdata_demande', 'field_bool'),
|
||||
('formdata_demande', 'field_itemOpen'),
|
||||
('formdata_demande', 'field_stringCaseSensitive-\xe9'),
|
||||
('formdata_demande', 'field_integer'),
|
||||
('formdata_demande', 'field_itemCaseSensitive-\xe9'),
|
||||
('formdata_demande', 'field_good_duplicate'),
|
||||
('formdata_demande', 'function__receiver'),
|
||||
('formdata_demande_field_good_duplicate', 'id'),
|
||||
('formdata_demande_field_good_duplicate', 'label'),
|
||||
('formdata_demande_field_item', 'id'),
|
||||
('formdata_demande_field_item', 'label'),
|
||||
('formdata_demande_field_itemCaseSensitive-é', 'id'),
|
||||
('formdata_demande_field_itemCaseSensitive-é', 'label'),
|
||||
('formdata_demande_field_itemOpen', 'id'),
|
||||
('formdata_demande_field_itemOpen', 'label'),
|
||||
('formdef', 'id'),
|
||||
|
@ -189,10 +191,11 @@ FULL OUTER JOIN public.dates AS dates ON series.date = dates.date WHERE dates.da
|
|||
with conn.cursor() as c:
|
||||
c.execute('SET search_path = olap')
|
||||
c.execute(
|
||||
'SELECT field_good_duplicate, count(id) '
|
||||
'FROM formdata_demande '
|
||||
'GROUP BY field_good_duplicate '
|
||||
'ORDER BY field_good_duplicate'
|
||||
'SELECT formdata_demande_field_good_duplicate.label, count(formdata_demande.id) '
|
||||
'FROM formdata_demande, formdata_demande_field_good_duplicate '
|
||||
'WHERE formdata_demande.field_good_duplicate = formdata_demande_field_good_duplicate.id '
|
||||
'GROUP BY formdata_demande_field_good_duplicate.label '
|
||||
'ORDER BY formdata_demande_field_good_duplicate.label'
|
||||
)
|
||||
assert dict(c.fetchall()) == {
|
||||
'a': 37,
|
||||
|
|
Loading…
Reference in New Issue