Merge branch 'master' of gitlab.com:kranklyboy/webapptemplate
This commit is contained in:
commit
7125142be7
@ -42,6 +42,9 @@ mongo.db.cars.update_one({"vin": "5GZCZ43D13S812716"}, {"$set": {"startingTime":
|
||||
|
||||
@app.route('/api/v1/resources/cars', methods=['GET'])
|
||||
def get_cars():
|
||||
"""
|
||||
Get all cars stored in entity ident database or filter by vin.
|
||||
"""
|
||||
query_parameters = request.args
|
||||
vin = query_parameters.get('vin')
|
||||
|
||||
@ -55,6 +58,10 @@ def get_cars():
|
||||
|
||||
@app.route('/api/v1/resources/traffic_lights', methods=['GET'])
|
||||
def get_traffic_lights():
|
||||
"""
|
||||
Get all traffic lights stored in entity ident database or filter by id.
|
||||
"""
|
||||
|
||||
query_parameters = request.args
|
||||
tl_id = query_parameters.get('id')
|
||||
|
||||
@ -69,6 +76,10 @@ def get_traffic_lights():
|
||||
|
||||
@app.route('/api/v1/resources/traffic_lights_geo', methods=['GET'])
|
||||
def get_traffic_lights_geo():
|
||||
"""
|
||||
Get traffic light which is in range and south of coordinates (lat, lon).
|
||||
"""
|
||||
|
||||
query_parameters = request.args
|
||||
|
||||
lat = float(query_parameters.get('lat'))
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
import unittest
|
||||
|
||||
import requests
|
||||
|
||||
from components.entitiy_ident.entity_ident_service.entity_ident_server import app
|
||||
|
||||
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
||||
|
||||
|
||||
class TestIdentServer(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.app = app.test_client()
|
||||
|
||||
def test_get_traffic_lights(self):
|
||||
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights')
|
||||
self.assertEqual(200, response.status_code)
|
||||
data = response.json()['cursor']
|
||||
self.assertIsNotNone(data[0]['id'])
|
||||
|
||||
def test_get_cars(self):
|
||||
response = requests.get(ENTITY_IDENT_URL + 'cars')
|
||||
self.assertEqual(200, response.status_code)
|
||||
data = response.json()['cursor']
|
||||
self.assertIsNotNone(data[0]['vin'])
|
||||
|
||||
def test_get_traffic_lights_geo(self):
|
||||
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights_geo?lat=47.92603&lon=16.20917')
|
||||
self.assertEqual(200, response.status_code)
|
||||
data = response.json()['cursor']
|
||||
self.assertEqual('3', data[0]['id'])
|
||||
Loading…
x
Reference in New Issue
Block a user