Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • web-et-numerique/factory/llle_project/enedis-sge-konnector
1 result
Select Git revision
Show changes
Commits on Source (7)
......@@ -12,6 +12,7 @@ default:
stages:
- test
- build
- deploy
- publish
sast:
......@@ -32,7 +33,7 @@ build-dev:
- git config --global user.email "$GIT_USER"
- git config --global user.password "$GIT_PWD"
- git config user.email "$GIT_USER"
- git remote set-url origin https://"$GIT_USER":"$GIT_PWD"@forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector.git
- git remote set-url origin https://"$GIT_USER":"$GIT_PWD"@forge.grandlyon.com/web-et-numerique/factory/llle_project/enedis-sge-konnector.git
- git config --global credential.helper store
- yarn deploy-dev
......@@ -65,12 +66,36 @@ build:
- git config --global user.email "$GIT_USER"
- git config --global user.password "$GIT_PWD"
- git config user.email "$GIT_USER"
- git remote set-url origin https://"$GIT_USER":"$GIT_PWD"@forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector.git
- git remote set-url origin https://"$GIT_USER":"$GIT_PWD"@forge.grandlyon.com/web-et-numerique/factory/llle_project/enedis-sge-konnector.git
- git config --global credential.helper store
- yarn deploy
only:
- main
deploy_dev:
stage: deploy
tags:
- deploy-alpha
script:
- cd /root/ecolyo-infra-scripts/cicid_scripts
- './update_sge_dev.sh'
environment:
name: dev
url: https://dev.cozy.self-data.alpha.grandlyon.com/
deploy_demo:
stage: deploy
tags:
- deploy-alpha
script:
- cd /root/ecolyo-infra-scripts/cicid_scripts
- './update_all_sge_dev.sh'
only:
- main
environment:
name: ecolyodemo
url: https://ecolyodemo.cozy.self-data.alpha.grandlyon.com/
publish:
stage: publish
before_script:
......
[[_TOC_]]
## Contexte
## Objectif
## Ressources
## Tâches
\ No newline at end of file
......@@ -45,7 +45,9 @@
"insee",
"konnectors",
"lastname",
"llle",
"maxpower",
"numerique",
"numero",
"Perimetre",
"periodicite",
......
......@@ -2,10 +2,15 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [1.2.2](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.1...v1.2.2) (2022-12-08)
### [1.2.3](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.2...v1.2.3) (2023-01-04)
### [1.2.1](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.0...v1.2.1) (2022-12-08)
### Bug Fixes
* factory url ([d092208](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/d0922088f2e9a09997978d1341672176a3d7e118))
* improve tolerance of insee code ([ca75b1d](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/ca75b1d9988c0f01f5ba7d9c2e39bda822550465))
### [1.2.2](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.1...v1.2.2) (2022-12-08)
### Features
......
const { errors } = require('cozy-konnector-libs')
const { getInseeCode } = require('../../src/requests/insee')
describe('getInseeCode', () => {
it('should return a valid insee code for Lyon 7', async () => {
expect(await getInseeCode(69007)).toEqual('69387')
......@@ -21,11 +22,60 @@ describe('getInseeCode', () => {
}
})
it('should return Craponne insee code for post code 69290', async () => {
expect(await getInseeCode(69290, 'CRAPONNE')).toEqual('69069')
})
describe('should handle communes with multiple insee code', () => {
it('should return Craponne insee code for post code 69290', async () => {
expect(await getInseeCode(69290, 'CRAPONNE')).toEqual('69069')
})
it('should return Pollionnay insee code for post code 69290', async () => {
expect(await getInseeCode(69290, 'POLLIONNAY')).toEqual('69154')
})
it('should return insee code for: Saint-bernard', async () => {
expect(await getInseeCode('01600', 'SAINT-BERNARD')).toEqual('01339')
})
it('should return insee code for: Neuville sur Saône', async () => {
expect(await getInseeCode(69250, 'Neuville sur Saône')).toEqual('69143')
})
it("should return insee code for: L'isle d'abeau", async () => {
expect(await getInseeCode(38080, "L'isle d'abeau")).toEqual('38193')
})
describe("should return correct insee code for Couzon-au-Mont-d'Or", () => {
it("should return insee code for: Couzon au mont d'or", async () => {
expect(await getInseeCode(69270, "Couzon au mont d'or")).toEqual(
'69068'
)
})
it('should return insee code for: Couzon au mont dʼor', async () => {
expect(await getInseeCode(69270, 'Couzon au mont dʼor')).toEqual(
'69068'
)
})
it("should return insee code for: Couzon-au-mont-d'or", async () => {
expect(await getInseeCode(69270, "Couzon-au-mont-d'or")).toEqual(
'69068'
)
})
it('should return insee code for: Couzon au mont d or', async () => {
expect(await getInseeCode(69270, 'Couzon au mont d or')).toEqual(
'69068'
)
})
})
it('should return Pollionnay insee code for post code 69290', async () => {
expect(await getInseeCode(69290, 'POLLIONNAY')).toEqual('69154')
describe('should return correct insee code for Fontaines-sur-Saône', () => {
it('should return insee code for: Fontaines-sur-Saône', async () => {
expect(await getInseeCode(69270, 'Fontaines-sur-Saône')).toEqual(
'69088'
)
})
it('should return insee code for: Fontaines-sur-Saone', async () => {
expect(await getInseeCode(69270, 'Fontaines-sur-Saone')).toEqual(
'69088'
)
})
})
})
})
{
"version": "1.2.2",
"version": "1.2.3",
"name": "Enedis SGE",
"type": "konnector",
"language": "node",
......
{
"name": "enedissgegrandlyon",
"version": "1.2.2",
"version": "1.2.3",
"description": "",
"repository": {
"type": "https",
......
......@@ -21,8 +21,10 @@ async function getInseeCode(postalCode, city) {
} else {
if (!city) throw new Error('No city')
const parsedCity = sanitizeCity(city)
const filteredResponse = response.data.filter(
town => town.nomCommune.toLowerCase() === city.toLowerCase()
town => sanitizeCity(town.nomCommune) === parsedCity
)
return filteredResponse[0].codeCommune
}
......@@ -34,6 +36,38 @@ async function getInseeCode(postalCode, city) {
}
}
/**
* Clean city input and remove all characters such as (^, ¨, ʼ, ', -, é, è)
* @param {string} city
* @return {string} parsedCity
*/
function sanitizeCity(city) {
return city
.toLowerCase()
.replace(/[âêîôûäëïü-\sʼ'éèç]/g, match => REPLACE_CHARS[match])
.trim()
}
const REPLACE_CHARS = {
â: 'a',
ê: 'e',
î: 'i',
ô: 'o',
û: 'u',
ä: 'a',
ë: 'e',
ï: 'i',
ö: 'o',
ü: 'u',
'-': '',
' ': '',
ʼ: '',
"'": '',
é: 'e',
è: 'e',
ç: 'c',
}
module.exports = {
getInseeCode,
}