Remove quartiers prioritaires
This commit is contained in:
parent
f6aef9fb66
commit
52d2ace823
12 changed files with 7 additions and 223 deletions
|
@ -1,52 +1,4 @@
|
|||
describe ApiCarto::API do
|
||||
describe '.search_qp' do
|
||||
subject { described_class.search_qp(geojson) }
|
||||
|
||||
before do
|
||||
stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search")
|
||||
.with(:body => /.*/,
|
||||
:headers => { 'Content-Type' => 'application/json' })
|
||||
.to_return(status: status, body: body)
|
||||
end
|
||||
context 'when geojson is empty' do
|
||||
let(:geojson) { '' }
|
||||
let(:status) { 404 }
|
||||
let(:body) { '' }
|
||||
|
||||
it 'raises ApiCarto::API::ResourceNotFound' do
|
||||
expect { subject }.to raise_error(ApiCarto::API::ResourceNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when request return 500' do
|
||||
let(:geojson) { File.read('spec/fixtures/files/api_carto/request_qp.json') }
|
||||
let(:status) { 500 }
|
||||
let(:body) { 'toto' }
|
||||
|
||||
it 'raises ApiCarto::API::ResourceNotFound' do
|
||||
expect { subject }.to raise_error(ApiCarto::API::ResourceNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when geojson exist' do
|
||||
let(:geojson) { File.read('spec/fixtures/files/api_carto/request_qp.json') }
|
||||
let(:status) { 200 }
|
||||
let(:body) { 'toto' }
|
||||
|
||||
it 'returns response body' do
|
||||
expect(subject).to eq(body)
|
||||
end
|
||||
|
||||
context 'when geojson is at format JSON' do
|
||||
let(:geojson) { JSON.parse(File.read('spec/fixtures/files/api_carto/request_qp.json')) }
|
||||
|
||||
it 'returns response body' do
|
||||
expect(subject).to eq(body)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.search_cadastre' do
|
||||
subject { described_class.search_cadastre(geojson) }
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
describe ApiCarto::QuartiersPrioritairesAdapter do
|
||||
subject { described_class.new(coordinates).results }
|
||||
|
||||
before do
|
||||
stub_request(:post, "https://sandbox.geo.api.gouv.fr/apicarto/quartiers-prioritaires/search")
|
||||
.with(:body => /.*/,
|
||||
:headers => { 'Content-Type' => 'application/json' })
|
||||
.to_return(status: status, body: body)
|
||||
end
|
||||
|
||||
context 'coordinates are filled' do
|
||||
let(:coordinates) { '[[2.252728, 43.27151][2.323223, 32.835332]]' }
|
||||
let(:status) { 200 }
|
||||
let(:body) { File.read('spec/fixtures/files/api_carto/response_qp.json') }
|
||||
|
||||
it { expect(subject).to be_a_instance_of(Array) }
|
||||
|
||||
context 'Attributes' do
|
||||
let(:qp_code) { 'QP057019' }
|
||||
|
||||
it { expect(subject.first[:code]).to eq(qp_code) }
|
||||
it { expect(subject.first[:nom]).to eq('Hauts De Vallières') }
|
||||
it { expect(subject.first[:commune]).to eq('Metz') }
|
||||
|
||||
it { expect(subject.first[:geometry]).to eq({ :type => "MultiPolygon", :coordinates => [[[[6.2136923480551, 49.1342109827851], [6.21416055031881, 49.1338823553928]]]] }) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'coordinates are empty' do
|
||||
let(:coordinates) { '' }
|
||||
let(:status) { 404 }
|
||||
let(:body) { '' }
|
||||
|
||||
it { expect { subject }.to raise_error(ApiCarto::API::ResourceNotFound) }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue