Projet

Général

Profil

0001-grandlyon-streetsections-update-for-new-format-of-co.patch

Frédéric Péters, 28 novembre 2022 10:58

Télécharger (3,26 ko)

Voir les différences:

Subject: [PATCH] grandlyon streetsections: update for new format of commune
 names (#71764)

 .../grandlyon_streetsections/models.py        |  1 +
 tests/test_grandlyon_streetsections.py        | 39 +++++++++++++++++++
 2 files changed, 40 insertions(+)
passerelle/contrib/grandlyon_streetsections/models.py
131 131
            )
132 132
            for attribute in ('nom', 'nomcommune', 'domanialite', 'codeinsee'):
133 133
                setattr(section, attribute, value.get(attribute) or '')
134
            section.nomcommune = normalize_commune(section.nomcommune)
134 135
            for attribute in ('bornemindroite', 'bornemingauche', 'bornemaxdroite', 'bornemaxgauche', 'gid'):
135 136
                if value.get(attribute) in (None, 'None'):
136 137
                    # data.grandlyon returned 'None' as a string at a time
tests/test_grandlyon_streetsections.py
209 209
         "senscircspecialise" : null,
210 210
         "senscirculation" : "Double",
211 211
         "typecirculation" : "générale"
212
      },
213
      {
214
         "bornemaxdroite" : 10,
215
         "bornemaxgauche" : 11,
216
         "bornemindroite" : 2,
217
         "bornemingauche" : 1,
218
         "codefuv" : "21424",
219
         "codeinsee" : "69266",
220
         "codetroncon" : "T54753",
221
         "datecreation" : "1995-07-17 18:43:00+02:00",
222
         "datedomanialite" : null,
223
         "datemajalpha" : "2022-11-14",
224
         "datemajborne" : "2022-07-26",
225
         "datemajgraph" : "2022-07-26",
226
         "denomroutiere" : null,
227
         "domanialite" : "Métropole",
228
         "gestionnaire" : null,
229
         "gid" : 30067,
230
         "importance" : "Petite rue",
231
         "nom" : "Rue de l'Avenir",
232
         "nomcommune" : "Villeurbanne",
233
         "observation" : null,
234
         "particularite" : null,
235
         "referencedomanialite" : null,
236
         "senscircspecialise" : null,
237
         "senscirculation" : "Inverse",
238
         "typecirculation" : "Générale"
212 239
      }
213 240
   ]
214 241
}
......
238 265
        connector.daily()
239 266
        assert StreetSection.objects.get(codetroncon='T5869').bornemindroite == 0
240 267
        assert StreetSection.objects.get(codetroncon='T5869').bornemaxdroite == 99999
268

  
269

  
270
def test_non_uppercase_communes(app, connector):
271
    StreetSection.objects.all().delete()
272
    with HTTMock(data_mock):
273
        connector.daily()
274
        response = app.get(
275
            "/grandlyon-streetsections/gl-streetsections/section_info"
276
            "?streetname=Rue de l'Avenir&commune=Villeurbanne&streetnumber=8"
277
        )
278
        assert response.json['err'] == 0
279
        assert response.json['data']['codetroncon'] == 'T54753'
241
-