Skip to content

Commit

Permalink
chore: remove stub for ods
Browse files Browse the repository at this point in the history
  • Loading branch information
rmonnier9 committed Dec 17, 2024
1 parent aaa2a6d commit 26133f2
Show file tree
Hide file tree
Showing 22 changed files with 920 additions and 64 deletions.
2 changes: 1 addition & 1 deletion clients/_test/clientBodacc/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clientBodacc from '#clients/open-data-soft/clients/bodacc';
import { clientBodacc } from '#clients/open-data-soft/clients/bodacc';
import { IAnnoncesBodacc } from '#models/annonces';
import { Siren } from '#utils/helpers';
import { expectClientToMatchSnapshot } from '../expect-client-to-match-snapshot';
Expand Down
24 changes: 3 additions & 21 deletions clients/open-data-soft/clients/annuaire-service-public/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpNotFound } from '#clients/exceptions';
import odsClient from '#clients/open-data-soft';
import routes from '#clients/routes';
import { stubClient } from '#clients/stub-client-with-snaphots';
import constants from '#models/constants';
import { IServicePublic } from '#models/service-public';
import { removeSpecialChars, Siret } from '#utils/helpers';
Expand Down Expand Up @@ -57,7 +56,7 @@ function queryAnnuaireServicePublic(whereQuery: string) {
);
}

const clientAnnuaireServicePublicByName = async (
export const clientAnnuaireServicePublicByName = async (
name: string
): Promise<IServicePublic> => {
// Query by name, it allows to find DINUM or ONF for instance.
Expand All @@ -78,7 +77,7 @@ const clientAnnuaireServicePublicByName = async (
};
};

const clientAnnuaireServicePublicByIds = async (
export const clientAnnuaireServicePublicByIds = async (
ids: string[]
): Promise<IServicePublic[]> => {
const query = `id="${ids.join('" OR id="')}"`;
Expand All @@ -91,7 +90,7 @@ const clientAnnuaireServicePublicByIds = async (
return response.records.map(mapToDomainObject);
};

const clientAnnuaireServicePublicBySiret = async (
export const clientAnnuaireServicePublicBySiret = async (
siret: Siret
): Promise<IServicePublic> => {
let response = await queryAnnuaireServicePublic(`siret="${siret}"`);
Expand Down Expand Up @@ -264,20 +263,3 @@ function mapToLiens(record: IServicePublicRecord) {

return liens;
}

const stubbedClientAnnuaireServicePublicByIds = stubClient({
clientAnnuaireServicePublicByIds,
});

const stubbedClientAnnuaireServicePublicBySiret = stubClient({
clientAnnuaireServicePublicBySiret,
});

const stubbedClientAnnuaireServicePublicByName = stubClient({
clientAnnuaireServicePublicByName,
});
export {
stubbedClientAnnuaireServicePublicByIds as clientAnnuaireServicePublicByIds,
stubbedClientAnnuaireServicePublicByName as clientAnnuaireServicePublicByName,
stubbedClientAnnuaireServicePublicBySiret as clientAnnuaireServicePublicBySiret,
};
9 changes: 1 addition & 8 deletions clients/open-data-soft/clients/bilans-financiers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpNotFound } from '#clients/exceptions';
import odsClient from '#clients/open-data-soft';
import routes from '#clients/routes';
import { stubClient } from '#clients/stub-client-with-snaphots';
import { IBilanFinancier } from '#models/finances-societe/types';
import { Siren } from '#utils/helpers';
import { getFiscalYear } from '#utils/helpers/formatting/format-fiscal-year';
Expand All @@ -11,7 +10,7 @@ import { IAPIBilanResponse } from './interface';
* Données financière (Ratios Financiers (BCE / INPI))
* https://data.economie.gouv.fr/explore/dataset/ratios_inpi_bce/api
*/
const clientBilansFinanciers = async (siren: Siren) => {
export const clientBilansFinanciers = async (siren: Siren) => {
const url = routes.donneesFinancieres.ods.search;
const metaDataUrl = routes.donneesFinancieres.ods.metadata;

Expand Down Expand Up @@ -129,9 +128,3 @@ const mapToBilan = (financialData: IAPIBilanResponse): IBilanFinancier => {
year: getFiscalYear(date_cloture_exercice),
};
};

const stubbedClientBilansFinanciers = stubClient({
clientBilansFinanciers,
});

export { stubbedClientBilansFinanciers as clientBilansFinanciers };
9 changes: 1 addition & 8 deletions clients/open-data-soft/clients/bodacc/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import odsClient from '#clients/open-data-soft';
import routes from '#clients/routes';
import { stubClient } from '#clients/stub-client-with-snaphots';
import { IAnnoncesBodacc } from '#models/annonces';
import { Exception } from '#models/exceptions';
import { Siren, formatDate } from '#utils/helpers';
Expand Down Expand Up @@ -47,7 +46,7 @@ interface IBodaccB extends IBodaccCoreRecord {
radiationaurcs?: string; // "{\"radiationPM\": \"O\"}"
}

const clientBodacc = async (siren: Siren): Promise<IAnnoncesBodacc> => {
export const clientBodacc = async (siren: Siren): Promise<IAnnoncesBodacc> => {
const searchUrl = `${routes.bodacc.ods.search}&q=registre%3A${siren}&sort=dateparution&facet=publicationavis&facet=publicationavis_facette&facet=typeavis&facet=typeavis_lib&facet=familleavis&facet=familleavis_lib&facet=numerodepartement&facet=departement_nom_officiel`;
const metaDataUrl = routes.bodacc.ods.metadata;
const response = await odsClient({ url: searchUrl }, metaDataUrl);
Expand Down Expand Up @@ -179,9 +178,3 @@ class BodaccParsingException extends Exception {
super({ name: 'BodaccParsingException', ...args });
}
}

const stubbedClientBodacc = stubClient({
clientBodacc,
});

export default stubbedClientBodacc;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import routes from '#clients/routes';
import { stubClient } from '#clients/stub-client-with-snaphots';
import { IAnnoncesAssociation } from '#models/annonces';
import constants from '#models/constants';
import { IdRna, Siren, formatDateLong } from '#utils/helpers';
Expand Down Expand Up @@ -63,7 +62,9 @@ type IDCAField = {
dca_datevalidation: string;
};

const clientJOAFE = async (idRna: string): Promise<IAnnoncesAssociation> => {
export const clientJOAFE = async (
idRna: string
): Promise<IAnnoncesAssociation> => {
const searchUrl = `${routes.journalOfficielAssociations.ods.search}&q=numero_rna=${idRna}&refine.source=joafe&sort=dateparution`;
const metaDataUrl = routes.journalOfficielAssociations.ods.metadata;
const response = await odsClient(
Expand All @@ -88,7 +89,7 @@ const clientJOAFE = async (idRna: string): Promise<IAnnoncesAssociation> => {
/**
* DCA Dépôt des Compotes des Associations
**/
const clientDCA = async (
export const clientDCA = async (
siren: Siren,
idRna: IdRna | string
): Promise<IAnnoncesAssociation> => {
Expand All @@ -114,12 +115,3 @@ const clientDCA = async (
lastModified: response.lastModified,
};
};

const stubbedClientDCA = stubClient({
clientDCA,
});
const stubbedClientJOAFE = stubClient({
clientJOAFE,
});

export { stubbedClientDCA as clientDCA, stubbedClientJOAFE as clientJOAFE };
9 changes: 1 addition & 8 deletions clients/open-data-soft/clients/qualiopi/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import odsClient from '#clients/open-data-soft';
import routes from '#clients/routes';
import { stubClient } from '#clients/stub-client-with-snaphots';
import { IOrganismeFormation } from '#models/certifications/organismes-de-formation';
import { Siren } from '#utils/helpers';
import { IOrganismesFormationRecord } from './type';
Expand All @@ -9,7 +8,7 @@ import { IOrganismesFormationRecord } from './type';
* MTPEI - DGEFP
* https://dgefp.opendatasoft.com/explore/dataset/liste-publique-des-of-v2/information/
*/
const clientOrganismeFormation = async (
export const clientOrganismeFormation = async (
siren: Siren
): Promise<IOrganismeFormation> => {
const response = await odsClient(
Expand Down Expand Up @@ -45,9 +44,3 @@ const mapToDomainObject = (record: IOrganismesFormationRecord) => {
: [],
};
};

const stubbedClientOrganismeFormation = stubClient({
clientOrganismeFormation,
});

export { stubbedClientOrganismeFormation as clientOrganismeFormation };
17 changes: 16 additions & 1 deletion cypress/e2e/annonces.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import routes from '#clients/routes';

describe('Annonces BODACC', () => {
beforeEach(() => {
cy.intercept('GET', `${routes.bodacc.ods.search}*`, {
fixture: '../fixtures/bodacc.json',
});
cy.intercept('GET', `${routes.bodacc.ods.metadata}*`, {
fixture: '../fixtures/ods-metadata.json',
});
});
it('Should display Annonces BODACC section', () => {
cy.visit('/annonces/880878145');
cy.contains('Annonces BODACC');
Expand All @@ -13,8 +23,13 @@ describe('Annonces BODACC', () => {
cy.contains('Radiations');
cy.contains('Annonce n°446, BODACC B n°20220227');
});

it('Should display JOAFE section for association', () => {
cy.intercept('GET', `${routes.journalOfficielAssociations.ods.search}*`, {
fixture: '../fixtures/journal-officiel-associations.json',
});
cy.intercept('GET', `${routes.journalOfficielAssociations.ods.metadata}*`, {
fixture: '../fixtures/ods-metadata.json',
});
cy.visit('/annonces/338365059');
cy.contains(
/Cette structure possède [\d] annonces publiées au Journal Officiel des Associations/
Expand Down
14 changes: 14 additions & 0 deletions cypress/e2e/bilans-financiers.cy.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import routes from '#clients/routes';

describe('Bilans financiers', () => {
it('Should display Données financières section', () => {
cy.visit('/entreprise/487444697');
cy.contains('Données financières');
});

it('Should hide bilans when partially confidential', () => {
cy.intercept('GET', `${routes.donneesFinancieres.ods.search}*`, {
fixture: '../fixtures/donnees-financieres-confidential.json',
});
cy.intercept('GET', `${routes.donneesFinancieres.ods.metadata}*`, {
fixture: '../fixtures/ods-metadata.json',
});
cy.visit('/donnees-financieres/487444697');
cy.contains(
'Les bilans de cette structure sont accompagnés d’une déclaration de confidentialité.'
);
});

it('Should display indicateurs financiers', () => {
cy.intercept('GET', `${routes.donneesFinancieres.ods.search}*`, {
fixture: '../fixtures/donnees-financieres.json',
});
cy.intercept('GET', `${routes.donneesFinancieres.ods.metadata}*`, {
fixture: '../fixtures/ods-metadata.json',
});
cy.visit('/donnees-financieres/552032534');
cy.contains('Date de clôture');
cy.contains('31/12/2019');
Expand Down
Loading

0 comments on commit 26133f2

Please sign in to comment.