Commit 68e04100 authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Changed default port to 28111, added test for search routes (closes #3)

parent 261793cf
...@@ -20,12 +20,16 @@ npm install ...@@ -20,12 +20,16 @@ npm install
npm run start npm run start
``` ```
Here you are, you can access the API through `http://localhost:3000/`. Here you are, you can access the API through `http://localhost:28111/`.
If you are planning to run this server in a production context, you should think of using your own API keys for picture providers. To do so, you might change the `CREDENTIALS` variable in `api/controllers/P4CaaSController.js` file.
Unit tests are available, to run them just launch `npm run test`.
## Usage ## Usage
Just run HTTP queries over the API endpoint (by default `http://localhost:3000/`). Documentation can be accessed at `/doc`. Just run HTTP queries over the API endpoint (by default `http://localhost:28111/`). Documentation can be accessed at `/doc`.
## Contributing ## Contributing
......
...@@ -24,7 +24,7 @@ global.XMLHttpRequest.DONE = 4; ...@@ -24,7 +24,7 @@ global.XMLHttpRequest.DONE = 4;
const express = require('express'), const express = require('express'),
bodyParser = require('body-parser'), bodyParser = require('body-parser'),
app = express(), app = express(),
port = process.env.PORT || 3000; port = process.env.PORT || 28111;
app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json()); app.use(bodyParser.json());
......
...@@ -168,7 +168,7 @@ describe('Server routes', function() { ...@@ -168,7 +168,7 @@ describe('Server routes', function() {
it("should return pictures on GET with coordinates + radius only", function(done){ it("should return pictures on GET with coordinates + radius only", function(done){
request(server) request(server)
.get("/search/around?lat=48.125&lng=-1.69&radius=500") .get("/search/around?lat=48.125&lng=-1.69&radius=250")
.expect("Content-type",/json/) .expect("Content-type",/json/)
.expect(200) .expect(200)
.end(function(err, res){ .end(function(err, res){
...@@ -186,7 +186,30 @@ describe('Server routes', function() { ...@@ -186,7 +186,30 @@ describe('Server routes', function() {
}); });
}).timeout(15000); }).timeout(15000);
//TODO Test with all parameters it("should return pictures on GET with coordinates, radius, date parameters", function(done){
request(server)
.get("/search/around?lat=48.125&lng=-1.69&radius=250&mindate=1493596800000&maxdate=1498867200000")
.expect("Content-type",/json/)
.expect(200)
.end(function(err, res){
assert.equal(res.status, 200);
assert.equal(res.body.status, "OK");
assert.ok(res.body.pictures.length > 0);
for(const p of res.body.pictures) {
assert.ok(p.pictureUrl.startsWith("http"));
assert.ok(p.date >= 1493596800000);
assert.ok(p.date <= 1498867200000);
assert.ok(p.coordinates !== undefined);
assert.ok(p.provider !== undefined);
assert.ok(p.author !== undefined);
assert.ok(p.license !== undefined);
assert.ok(p.detailsUrl.startsWith("http"));
}
done();
});
}).timeout(15000);
}); });
describe('/fetchers', function() { describe('/fetchers', function() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment