Migrate API Entreprise INSEE V1 to V2

This commit is contained in:
Xavier J 2016-06-13 10:13:37 +02:00
parent 2791988da2
commit d7eee773da
12 changed files with 152 additions and 59 deletions

View file

@ -4,7 +4,7 @@ describe SIADE::API do
describe '.entreprise' do
subject { described_class.entreprise(siren) }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
context 'when siren does not exist' do
@ -30,7 +30,7 @@ describe SIADE::API do
describe '.etablissement' do
subject { described_class.etablissement(siret) }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
@ -57,7 +57,7 @@ describe SIADE::API do
describe '.exercices' do
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/etablissements\/exercices\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/etablissements\/exercices\/.*token=/)
.to_return(status: status, body: body)
end
@ -88,7 +88,7 @@ describe SIADE::API do
describe '.rna' do
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/associations\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/associations\/.*token=/)
.to_return(status: status, body: body)
end

View file

@ -4,7 +4,7 @@ describe SIADE::EntrepriseAdapter do
subject { described_class.new('418166096').to_params }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/418166096?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/418166096?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
end
@ -18,7 +18,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien un capital_social' do
expect(subject[:capital_social]).to eq(372_795)
expect(subject[:capital_social]).to eq(462308)
end
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
@ -46,11 +46,11 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien un code_effectif_entreprise' do
expect(subject[:code_effectif_entreprise]).to eq('22')
expect(subject[:code_effectif_entreprise]).to eq('31')
end
it 'L\'entreprise contient bien une date_creation' do
expect(subject[:date_creation]).to eq('Mon, 01 Jan 1900 00:00:00.000000000 +0100')
expect(subject[:date_creation]).to eq('Wed, 01 Apr 1998 00:00:00.000000000 +0200')
end
it 'L\'entreprise contient bien un nom' do

View file

@ -6,7 +6,7 @@ describe SIADE::EtablissementAdapter do
subject { described_class.new(siret).to_params }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
end
@ -33,7 +33,7 @@ describe SIADE::EtablissementAdapter do
context 'Concaténation lignes adresse' do
it 'L\'entreprise contient bien une adresse sur plusieurs lignes' do
expect(subject[:adresse]).to eq("OCTO-TECHNOLOGY\r\n50 AV DES CHAMPS ELYSEES\r\n75008 PARIS 8\r\nligne 4\r\nligne 5\r\n")
expect(subject[:adresse]).to eq("OCTO TECHNOLOGY\r\n50 AVENUE DES CHAMPS ELYSEES\r\n75008 PARIS\r\nFRANCE\r\n")
end
end
@ -73,7 +73,7 @@ describe SIADE::EtablissementAdapter do
subject { described_class.new(bad_siret).to_params }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
.to_return(body: 'Fake body', status: 404)
end

View file

@ -5,7 +5,7 @@ describe SIADE::ExercicesAdapter do
subject { described_class.new(siret).to_params }
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/etablissements\/exercices\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/etablissements\/exercices\/.*token=/)
.to_return(body: File.read('spec/support/files/exercices.json', status: 200))
end

View file

@ -8,7 +8,7 @@ describe SIADE::RNAAdapter do
subject { described_class.new(siret).to_params }
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/associations\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/associations\/.*token=/)
.to_return(body: body, status: status)
end