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 (8)
......@@ -12,7 +12,7 @@ default:
stages:
- test
- build
- deploy
- update-instances
- publish
sast:
......@@ -72,20 +72,21 @@ build:
only:
- main
deploy_dev:
stage: deploy
update-dev:
stage: update-instances
tags:
- deploy-alpha
script:
- cd /root/ecolyo-infra-scripts/cicid_scripts
- './update_sge_dev.sh'
only:
- merge_requests
environment:
name: dev
url: https://dev.cozy.self-data.alpha.grandlyon.com/
when: manual
deploy_demo:
stage: deploy
update-all:
stage: update-instances
tags:
- deploy-alpha
script:
......
......@@ -34,6 +34,7 @@
"criteres",
"Derniere",
"Detaillees",
"enedis",
"Enedis",
"enedissgegrandlyon",
"Etage",
......
......@@ -2,6 +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.5](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.4...v1.2.5) (2023-02-03)
### Bug Fixes
* change errors for enedis routes ([bb63b8c](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/bb63b8cc9b1475a5d7037fdf9233f585a220e8dd))
* **insee api:** handle apostrophe ([5751f3f](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/5751f3f1333de6160e8acf8a0cb3cdb0e6a040ff))
* **insee:** cleaner regexp ([e38b802](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/commit/e38b80221cef17f7229a29ce16f3fd3356c802d1))
### [1.2.4](https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector/compare/v1.2.3...v1.2.4) (2023-01-24)
......
......@@ -36,12 +36,12 @@ describe('activateContract', () => {
)
expect(serviceId).toBe(78232791)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
mockParseServiceId.mockRestore()
})
it('should throw LOGIN_FAILED when request fail 🚫', async () => {
it('should throw CAPTCHA_RESOLUTION_FAILED when request fail 🚫', async () => {
mockSoapRequest.mockRejectedValueOnce('reject')
try {
await activateContract(
......@@ -56,12 +56,12 @@ describe('activateContract', () => {
)
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
mockParseServiceId.mockRestore()
})
it('should throw LOGIN_FAILED when failing parsing 🚫', async () => {
it('should throw CAPTCHA_RESOLUTION_FAILED when failing parsing 🚫', async () => {
mockSoapRequest.mockResolvedValueOnce(responseMock)
jest.spyOn(xml2js, 'parseStringPromise').mockResolvedValueOnce({
Envelope: {
......@@ -87,7 +87,7 @@ describe('activateContract', () => {
)
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
mockParseServiceId.mockRestore()
......
......@@ -74,7 +74,7 @@ describe('verifyContract', () => {
)
expect(serviceId).toBe(78232791)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
mockParseContracts.mockRestore()
......@@ -126,7 +126,7 @@ describe('verifyContract', () => {
)
expect(serviceId).toBe(78232791)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
mockParseContracts.mockRestore()
......@@ -186,12 +186,12 @@ describe('verifyContract', () => {
)
expect(serviceId).toBe(null)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
mockParseContracts.mockRestore()
})
it('should return LOGIN_FAILED if issue in request 🚫', async () => {
it('should return CAPTCHA_RESOLUTION_FAILED if issue in request 🚫', async () => {
mockSoapRequest.mockRejectedValueOnce('reject')
try {
......@@ -204,10 +204,10 @@ describe('verifyContract', () => {
)
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
})
it('should return LOGIN_FAILED if issue in parsing 🚫', async () => {
it('should return CAPTCHA_RESOLUTION_FAILED if issue in parsing 🚫', async () => {
mockSoapRequest.mockResolvedValue(responseMock)
jest.spyOn(xml2js, 'parseStringPromise').mockResolvedValueOnce({
Envelope: {
......@@ -229,7 +229,7 @@ describe('verifyContract', () => {
)
expect(true).toBe(false)
} catch (error) {
expect(error).toBe(errors.LOGIN_FAILED)
expect(error).toBe(errors.CAPTCHA_RESOLUTION_FAILED)
}
})
it('should return NULL if no contract are found 🚫', async () => {
......
......@@ -42,6 +42,18 @@ describe('getInseeCode', () => {
expect(await getInseeCode(38080, "L'isle d'abeau")).toEqual('38193')
})
it('should return insee code for: Ervauville', async () => {
expect(await getInseeCode('45320', 'Ervauville')).toEqual('45136')
})
it('should return insee code for: Marcy l’Etoile', async () => {
expect(await getInseeCode('69280', 'Marcy l’Etoile')).toEqual('69127')
})
it('should return insee code for: Brignais', async () => {
expect(await getInseeCode('69530', 'Brignais')).toEqual('69027')
})
describe('should handle communes with "Saint" or "St"', () => {
it("should return insee code for: Saint Romain au Mont d'Or", async () => {
expect(await getInseeCode(69270, "Saint Romain au Mont d'Or")).toEqual(
......@@ -76,6 +88,20 @@ describe('getInseeCode', () => {
it('should return insee code for: Puget-Rostang', async () => {
expect(await getInseeCode('06260', 'Puget-Rostang')).toEqual('06098')
})
it('should return insee code for: Rostrenen', async () => {
expect(await getInseeCode(22110, 'Rostrenen')).toEqual('22266')
})
it('should return insee code for: Kergrist Moëlou', async () => {
expect(await getInseeCode(22110, 'Kergrist Moëlou')).toEqual('22087')
})
it('should return insee code for: castets', async () => {
expect(await getInseeCode(40260, 'castets')).toEqual('40075')
})
it('should return insee code for: Fontaines st Martin', async () => {
expect(await getInseeCode(69270, 'Fontaines st Martin')).toEqual(
'69087'
)
})
it('should return insee code for: St léger', async () => {
expect(await getInseeCode('06260', 'St léger')).toEqual('06124')
})
......
{
"version": "1.2.4",
"version": "1.2.5",
"name": "Enedis SGE",
"type": "konnector",
"language": "node",
......
{
"name": "enedissgegrandlyon",
"version": "1.2.4",
"version": "1.2.5",
"description": "",
"repository": {
"type": "https",
......
......@@ -47,7 +47,7 @@ async function activateContract(
log('error', 'commanderCollectePublicationMesures')
log('error', err)
Sentry.captureException('commanderCollectePublicationMesures', err)
throw errors.LOGIN_FAILED
throw errors.CAPTCHA_RESOLUTION_FAILED
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
......@@ -71,7 +71,7 @@ async function activateContract(
//TODO: handle SGT4B8: Il existe déjà plusieurs demandes en cours sur le point ?
//TODO: handle SGT4H9: La demande ne porte pas sur un point équipé d'un compteur communicant ouvert aux services niveau 2.
//TODO: handle SGT589: La demande ne peut pas aboutir car le compteur n'est actuellement pas téléopérable.
throw errors.LOGIN_FAILED
throw errors.CAPTCHA_RESOLUTION_FAILED
}
}
......
......@@ -34,7 +34,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
log('error', 'rechercherServicesSouscritsMesures')
log('error', err)
Sentry.captureException('rechercherServicesSouscritsMesures', err)
throw errors.LOGIN_FAILED
throw errors.CAPTCHA_RESOLUTION_FAILED
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
......@@ -77,7 +77,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
'error',
'if an error is thrown here, it probably means that the contract has already been open today and that enedis cannot open a second one. Wait until tomorow to try again'
)
throw errors.LOGIN_FAILED
throw errors.CAPTCHA_RESOLUTION_FAILED
}
}
......
......@@ -22,6 +22,7 @@ async function getInseeCode(postalCode, city) {
if (!city) throw new Error('No city')
const parsedCity = sanitizeCity(city)
console.log(parsedCity)
const filteredResponse = response.data.filter(
town => sanitizeCity(town.nomCommune) === parsedCity
......@@ -45,8 +46,8 @@ async function getInseeCode(postalCode, city) {
function sanitizeCity(city) {
return city
.toLowerCase()
.replace(/st/g, 'saint')
.replace(/[âêîôûäëïü-\sʼ'éèç]/g, match => REPLACE_CHARS[match])
.replace(/\bst\b/i, 'saint')
.replace(/[âêîôûäëïü-\sʼ'éèç]/g, match => REPLACE_CHARS[match])
.trim()
}
......@@ -65,6 +66,7 @@ const REPLACE_CHARS = {
' ': '',
ʼ: '',
"'": '',
'': '',
é: 'e',
è: 'e',
ç: 'c',
......