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'])
