3 Commits

Author SHA1 Message Date
1d6b334c74 fix; radius route
All checks were successful
Build Docker Image Front / run (pull_request) Successful in 24s
Build Docker Image Back / run (pull_request) Successful in 46s
JsDocs / coverage (pull_request) Successful in 39s
Test and coverage / coverage (pull_request) Successful in 1m12s
2024-05-16 10:15:13 +02:00
e700ae625a test rm rewire 2024-05-16 10:14:54 +02:00
2e9362cb32 add test form radius in bruno 2024-05-16 10:14:41 +02:00
4 changed files with 23 additions and 50 deletions

View File

@ -86,7 +86,7 @@ export async function getRadius(req:express.Request, res: express.Response) {
radius = "1000" radius = "1000"
} }
res.send(callRadius(lon,lat,radius as string)) res.send( await callRadius(lon,lat,radius as string))
} }
//TODO: fair une route ou l'on donne l'id un établicement pour avoir des détailles //TODO: fair une route ou l'on donne l'id un établicement pour avoir des détailles

View File

@ -2,7 +2,6 @@ import request from "supertest";
import app from "../src/app"; import app from "../src/app";
import { Server, IncomingMessage, ServerResponse } from "http"; import { Server, IncomingMessage, ServerResponse } from "http";
import * as dotenv from "dotenv"; import * as dotenv from "dotenv";
import rewire from 'rewire';
dotenv.config({path: '../../.env'}) dotenv.config({path: '../../.env'})
const port = parseInt(process.env.BAR_PORT || '3000') const port = parseInt(process.env.BAR_PORT || '3000')
@ -10,48 +9,6 @@ const port = parseInt(process.env.BAR_PORT || '3000')
let serveur : Server<typeof IncomingMessage, typeof ServerResponse> let serveur : Server<typeof IncomingMessage, typeof ServerResponse>
describe("Test the otm city path", () => { describe("Test the otm city path", () => {
const opentripmapModule = rewire("../src/openTripMaps")
const callCity = opentripmapModule.__get__("callCity")
const callRadius = opentripmapModule.__get__("callRadius")
test("Get city from OTM", async () => {
const res = {
"name": "Paris",
"country": "FR",
"lat": 48.85341,
"lon": 2.3488,
"population": 2138551,
"timezone": "Europe/Paris",
"status": "OK"
}
expect(await callCity("Paris")).toEqual(res)
})
test("Get bar in radius from OTM", async () => {
const res = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "562635",
"geometry": {
"type": "Point",
"coordinates": [
-1.4344594,
46.6686478
]
},
"properties": {
"xid": "N4032296324",
"name": "Le 27 point carré",
"dist": 0.17652159,
"rate": 1,
"osm": "node/4032296324",
"kinds": "foods,bars,tourist_facilities"
}
}]
}
expect(await callRadius("-1.4344594", "46.6686478", "10")).toEqual(res)
})
test("It should response the 200 code for GET method", done => { test("It should response the 200 code for GET method", done => {
request(app) request(app)
@ -120,7 +77,7 @@ describe("Test the otm city path", () => {
//TODO faire les test pour les cas d'erreur //TODO faire les test pour les cas d'erreur
test("Get bar in radius from API", done => { test("Get bar in radius from API", done => {
const res = { const out = {
"type": "FeatureCollection", "type": "FeatureCollection",
"features": [{ "features": [{
"type": "Feature", "type": "Feature",
@ -146,7 +103,7 @@ describe("Test the otm city path", () => {
.get("/otm/radius") .get("/otm/radius")
.query({'lon':'-1.4344594', 'lat' : '46.6686478', 'radius': '10'}) .query({'lon':'-1.4344594', 'lat' : '46.6686478', 'radius': '10'})
.then(response => { .then(response => {
expect(response.text).toEqual(JSON.stringify(res)); expect(response.text).toEqual(JSON.stringify(out));
done(); done();
}); });
}) })

View File

@ -5,15 +5,15 @@ meta {
} }
get { get {
url: {{TRIPMAP_URL}}/en/places/radius?radius=1000&lon=-1.43333&lat=46.66667&apikey={{OTM_KEY}}&kinds=bars,cafes,pubs,biergartens url: {{TRIPMAP_URL}}/en/places/radius?radius=10&lon=-1.4344594&lat=46.6686478&apikey={{OTM_KEY}}&kinds=bars,cafes,pubs,biergartens
body: none body: none
auth: none auth: none
} }
query { query {
radius: 1000 radius: 10
lon: -1.43333 lon: -1.4344594
lat: 46.66667 lat: 46.6686478
apikey: {{OTM_KEY}} apikey: {{OTM_KEY}}
kinds: bars,cafes,pubs,biergartens kinds: bars,cafes,pubs,biergartens
} }

View File

@ -0,0 +1,16 @@
meta {
name: otm_ex_radius
type: http
seq: 9
}
get {
url: http://localhost:3001/otm/city?name=La roche sur yon&radius=300
body: none
auth: none
}
query {
name: La roche sur yon
radius: 300
}