forked from etalab/apicarto
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from IGNF/#19233_tests_module_er
tests pour le module espace revendeur
- Loading branch information
Showing
3 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/*eslint-env node, mocha */ | ||
|
||
const request = require('supertest'); | ||
const expect = require('expect.js'); | ||
const app = require('../../../app'); | ||
|
||
const EXPECTED_PROPERTIES = [ | ||
"back_image", | ||
"background_color", | ||
"border_color", | ||
"category_id", | ||
"code_article", | ||
"code_ean", | ||
"collection_slug", | ||
"collection_title", | ||
"complement", | ||
"continent", | ||
"deleted_at", | ||
"departement", | ||
"dimension", | ||
"ean_symb", | ||
"edition_number", | ||
"editorial", | ||
"er_visible_from", | ||
"er_visible_to", | ||
"front_image", | ||
"full_description", | ||
"has_geometry", | ||
"keywords", | ||
"name", | ||
"name_complement", | ||
"pays", | ||
"previous_publication_date", | ||
"price", | ||
"price_excluding_vat", | ||
"pricecode", | ||
"print_medium", | ||
"producer", | ||
"publication_date", | ||
"region", | ||
"replacement", | ||
"sale", | ||
"scale", | ||
"segment_slug", | ||
"segment_title", | ||
"theme_slug", | ||
"theme_title", | ||
"tva_type", | ||
"updated_at", | ||
"vat" | ||
]; | ||
|
||
describe('Testing /api/er/category', function() { | ||
|
||
describe('With invalid inputs', function() { | ||
|
||
describe('With invalid type', function() { | ||
it('should reply with 400', function(done){ | ||
request(app) | ||
.get('/api/er/category?type=not_valid') | ||
.expect(400,done) | ||
; | ||
}); | ||
}); | ||
|
||
describe('With missing type argument', function() { | ||
it('should reply with 400', function(done){ | ||
request(app) | ||
.get('/api/er/category?name=CARTES DE RANDONNÉE') | ||
.expect(400,done) | ||
; | ||
}); | ||
}); | ||
}); | ||
|
||
describe('/api/er/category?name=CARTES DE RANDONNÉE&type=s', function() { | ||
it('should reply a FeatureCollection containing a valid Feature for name=CARTES DE RANDONNÉE & type=s', done => { | ||
request(app) | ||
.get('/api/er/category?name=CARTES DE RANDONNÉE&type=s') | ||
.expect(200) | ||
.expect(res => { | ||
const feature = res.body.features[0]; | ||
expect(feature.geometry.type).to.eql('MultiPolygon'); | ||
let propertyNames = Object.keys(feature.properties); | ||
propertyNames.sort(); | ||
expect(propertyNames).to.eql(EXPECTED_PROPERTIES); | ||
expect(feature.properties.name).to.eql("0317OT - ILE D'OUESSANT"); | ||
}) | ||
.end(done); | ||
}); | ||
}); | ||
|
||
describe('/api/er/category?category_id=13', function() { | ||
it('should reply a FeatureCollection containing a valid Feature for category_id=13', done => { | ||
request(app) | ||
.get('/api/er/category?category_id=13') | ||
.expect(200) | ||
.expect(res => { | ||
const feature = res.body.features[1]; | ||
expect(feature.geometry.type).to.eql('MultiPolygon'); | ||
let propertyNames = Object.keys(feature.properties); | ||
propertyNames.sort(); | ||
expect(propertyNames).to.eql(EXPECTED_PROPERTIES); | ||
|
||
expect(feature.properties.code_ean).to.eql(9782758553601); | ||
expect(feature.properties.code_article).to.eql('0416ET'); | ||
expect(feature.properties.name).to.eql('0416ET - PLOUGUERNEAU LES ABERS'); | ||
expect(feature.properties.name_complement).to.eql(null); | ||
expect(feature.properties.edition_number).to.eql('6'); | ||
expect(feature.properties.producer).to.eql('IGN'); | ||
expect(feature.properties.scale).to.eql('1:25 000'); | ||
expect(feature.properties.print_medium).to.eql('Papier standard'); | ||
expect(feature.properties.category_id).to.eql(13); | ||
expect(feature.properties.segment_title).to.eql('CARTES DE RANDONNÉE'); | ||
expect(feature.properties.theme_title).to.eql('TOP 25 ET SÉRIE BLEUE'); | ||
|
||
expect(feature.bbox).to.eql( | ||
[-4.82454566, | ||
48.44183799, | ||
-4.35927545, | ||
48.67786421]); | ||
}) | ||
.end(done); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*eslint-env node, mocha */ | ||
|
||
const request = require('supertest'); | ||
const expect = require('expect.js'); | ||
const app = require('../../../app'); | ||
|
||
const EXPECTED_PROPERTIES = [ | ||
"children", | ||
"deleted", | ||
"name", | ||
"title", | ||
"type", | ||
"zip_codes" | ||
]; | ||
|
||
describe('Testing /api/er/grid', function() { | ||
|
||
describe('With invalid inputs', function() { | ||
|
||
describe('With invalid geom', function() { | ||
it('should reply with 400', function(done){ | ||
request(app) | ||
.get('/api/er/grid?geom=not_valid') | ||
.expect(400,done) | ||
; | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('/api/er/grid?name=01025', function() { | ||
it('should reply a FeatureCollection containing a valid Feature for name=01025', done => { | ||
request(app) | ||
.get('/api/er/grid?name=01025') | ||
.expect(200) | ||
.expect(res => { | ||
const feature = res.body.features[0]; | ||
expect(feature.geometry.type).to.eql('MultiPolygon'); | ||
let propertyNames = Object.keys(feature.properties); | ||
propertyNames.sort(); | ||
expect(propertyNames).to.eql(EXPECTED_PROPERTIES); | ||
expect(feature.properties.title).to.eql("BAGE-DOMMARTIN"); | ||
}) | ||
.end(done); | ||
}); | ||
}); | ||
|
||
describe('/api/er/grid?title=BEAUPONT', function() { | ||
it('should reply a FeatureCollection containing a valid Feature for title=BEAUPONT', done => { | ||
request(app) | ||
.get('/api/er/grid?title=BEAUPONT') | ||
.expect(200) | ||
.expect(res => { | ||
const feature = res.body.features[0]; | ||
expect(feature.geometry.type).to.eql('MultiPolygon'); | ||
let propertyNames = Object.keys(feature.properties); | ||
propertyNames.sort(); | ||
expect(propertyNames).to.eql(EXPECTED_PROPERTIES); | ||
|
||
expect(feature.properties.name).to.eql('01029'); | ||
expect(feature.properties.type).to.eql('municipality'); | ||
expect(feature.properties.zip_codes).to.eql('[\"01270\"]'); | ||
expect(feature.properties.title).to.eql('BEAUPONT'); | ||
expect(feature.properties.deleted).to.eql('false'); | ||
expect(feature.properties.children).to.eql('[]'); | ||
|
||
expect(feature.bbox).to.eql( | ||
[5.23331158, | ||
46.39351348, | ||
5.29357027, | ||
46.46135244]); | ||
}) | ||
.end(done); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/*eslint-env node, mocha */ | ||
|
||
const request = require('supertest'); | ||
const expect = require('expect.js'); | ||
const app = require('../../../app'); | ||
|
||
const EXPECTED_PROPERTIES = [ | ||
"back_image", | ||
"background_color", | ||
"border_color", | ||
"category_id", | ||
"code_article", | ||
"code_ean", | ||
"collection_slug", | ||
"collection_title", | ||
"complement", | ||
"continent", | ||
"deleted_at", | ||
"departement", | ||
"dimension", | ||
"ean_symb", | ||
"edition_number", | ||
"editorial", | ||
"er_visible_from", | ||
"er_visible_to", | ||
"front_image", | ||
"full_description", | ||
"has_geometry", | ||
"keywords", | ||
"name", | ||
"name_complement", | ||
"pays", | ||
"previous_publication_date", | ||
"price", | ||
"price_excluding_vat", | ||
"pricecode", | ||
"print_medium", | ||
"producer", | ||
"publication_date", | ||
"region", | ||
"replacement", | ||
"sale", | ||
"scale", | ||
"segment_slug", | ||
"segment_title", | ||
"theme_slug", | ||
"theme_title", | ||
"tva_type", | ||
"updated_at", | ||
"vat" | ||
]; | ||
|
||
describe('Testing /api/er/product', function() { | ||
|
||
describe('With invalid inputs', function() { | ||
|
||
describe('With invalid code_ean', function() { | ||
it('should reply with 400', function(done){ | ||
request(app) | ||
.get('/api/er/product?code_ean=not_valid') | ||
.expect(400,done) | ||
; | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('/api/er/product?code_ean=99782758554226', function() { | ||
it('should reply a FeatureCollection containing a valid Feature for code_ean=99782758554226', done => { | ||
request(app) | ||
.get('/api/er/product?code_ean=9782758554226') | ||
.expect(200) | ||
.expect(res => { | ||
const feature = res.body.features[0]; | ||
expect(feature.geometry.type).to.eql('MultiPolygon'); | ||
let propertyNames = Object.keys(feature.properties); | ||
propertyNames.sort(); | ||
expect(propertyNames).to.eql(EXPECTED_PROPERTIES); | ||
expect(feature.properties.name).to.eql("0317OT - ILE D'OUESSANT"); | ||
}) | ||
.end(done); | ||
}); | ||
}); | ||
|
||
describe('/api/er/product?code_article=0416ET', function() { | ||
it('should reply a FeatureCollection containing a valid Feature for code_article=0416ET', done => { | ||
request(app) | ||
.get('/api/er/product?code_article=0416ET') | ||
.expect(200) | ||
.expect(res => { | ||
const feature = res.body.features[0]; | ||
expect(feature.geometry.type).to.eql('MultiPolygon'); | ||
let propertyNames = Object.keys(feature.properties); | ||
propertyNames.sort(); | ||
expect(propertyNames).to.eql(EXPECTED_PROPERTIES); | ||
|
||
expect(feature.properties.code_ean).to.eql(9782758553601); | ||
expect(feature.properties.code_article).to.eql('0416ET'); | ||
expect(feature.properties.name).to.eql('0416ET - PLOUGUERNEAU LES ABERS'); | ||
expect(feature.properties.name_complement).to.eql(null); | ||
expect(feature.properties.edition_number).to.eql('6'); | ||
expect(feature.properties.producer).to.eql('IGN'); | ||
expect(feature.properties.scale).to.eql('1:25 000'); | ||
expect(feature.properties.print_medium).to.eql('Papier standard'); | ||
expect(feature.properties.category_id).to.eql(13); | ||
expect(feature.properties.segment_title).to.eql('CARTES DE RANDONNÉE'); | ||
expect(feature.properties.theme_title).to.eql('TOP 25 ET SÉRIE BLEUE'); | ||
|
||
expect(feature.bbox).to.eql( | ||
[-4.82454566, | ||
48.44183799, | ||
-4.35927545, | ||
48.67786421]); | ||
}) | ||
.end(done); | ||
}); | ||
}); | ||
}); |