Compare commits
3 Commits
a672f48f7c
...
project/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| b171f42fa6 | |||
| 92c0acda2c | |||
| 058aac36c7 |
@@ -58,15 +58,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Build MapView testing container
|
- name: Build MapView testing container
|
||||||
working-directory: IoT-Systems
|
working-directory: IoT-Systems
|
||||||
run: docker build -t local/mapview/${{gitea.sha}} -f MapView/Dockerfile-test .
|
run: docker build -t local/mapview -f MapView/Dockerfile-test .
|
||||||
|
|
||||||
- name: Run MapView tests
|
- name: Run MapView tests
|
||||||
working-directory: IoT-Systems
|
working-directory: IoT-Systems
|
||||||
run: docker run --rm -it local/mapview/${{gitea.sha}}
|
run: docker run --rm -it -v $PWD/MapView:/app:ro local/mapview
|
||||||
|
|
||||||
- name: Clean up containers
|
|
||||||
if: ${{always()}}
|
|
||||||
run: docker image rm local/mapview/${{gitea.sha}}
|
|
||||||
|
|
||||||
integration-smoke-test:
|
integration-smoke-test:
|
||||||
name: Integration smoke testing
|
name: Integration smoke testing
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ WORKDIR /app
|
|||||||
COPY MapView/requirements.txt .
|
COPY MapView/requirements.txt .
|
||||||
RUN sed -i 's/==.*//' requirements.txt
|
RUN sed -i 's/==.*//' requirements.txt
|
||||||
|
|
||||||
|
RUN apt update && apt install -y libgl-dev libsdl1.2-dev
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
RUN pip install --root-user-action ignore --no-cache-dir unittest
|
RUN pip install --root-user-action ignore --no-cache-dir python-unittest kivy[base] pygame
|
||||||
# Copy the entire application into the container
|
|
||||||
COPY MapView/. .
|
|
||||||
# Run the main.py script inside the container when it starts
|
|
||||||
#CMD ["uvicorn", "main:app", "--host", "0.0.0.0"]
|
|
||||||
CMD ["./test-entry.sh"]
|
CMD ["./test-entry.sh"]
|
||||||
|
|||||||
@@ -39,7 +39,11 @@ class Datasource:
|
|||||||
self.connection_status = None
|
self.connection_status = None
|
||||||
self._new_points = []
|
self._new_points = []
|
||||||
self._active_markers = []
|
self._active_markers = []
|
||||||
|
|
||||||
|
try:
|
||||||
asyncio.ensure_future(self.connect_to_server())
|
asyncio.ensure_future(self.connect_to_server())
|
||||||
|
except RuntimeError:
|
||||||
|
Logger.info("No event loop detected, running in offline mode")
|
||||||
|
|
||||||
def get_new_points(self):
|
def get_new_points(self):
|
||||||
Logger.debug(self._new_points)
|
Logger.debug(self._new_points)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import sys
|
|||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
sys.modules['lineMapLayer'] = Mock()
|
sys.modules['lineMapLayer'] = Mock()
|
||||||
sys.modules['datasource'] = Mock()
|
|
||||||
sys.modules['config'] = Mock()
|
sys.modules['config'] = Mock()
|
||||||
|
|
||||||
from main import get_lat_lon, MapViewApp
|
from main import get_lat_lon, MapViewApp
|
||||||
@@ -79,6 +78,52 @@ class TestMapLatLonToProcessedAgentData(unittest.TestCase):
|
|||||||
result = self.instance.map_lat_lon_to_processed_agent_data(50.45, 30.52)
|
result = self.instance.map_lat_lon_to_processed_agent_data(50.45, 30.52)
|
||||||
|
|
||||||
self.assertIsNotNone(result)
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(result, marker)
|
||||||
|
|
||||||
|
def test_marker_is_close_enough(self):
|
||||||
|
marker = Mock()
|
||||||
|
marker.latitude = 30.521
|
||||||
|
marker.longitude = 50.452
|
||||||
|
|
||||||
|
self.instance._active_markers = [marker]
|
||||||
|
|
||||||
|
result = self.instance.map_lat_lon_to_processed_agent_data(50.45, 30.52)
|
||||||
|
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(result, marker)
|
||||||
|
|
||||||
|
def test_marker_is_too_far(self):
|
||||||
|
marker = Mock()
|
||||||
|
marker.latitude = 30.524
|
||||||
|
marker.longitude = 50.454
|
||||||
|
|
||||||
|
self.instance._active_markers = [marker]
|
||||||
|
|
||||||
|
result = self.instance.map_lat_lon_to_processed_agent_data(50.45, 30.52)
|
||||||
|
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_return_closer_marker(self):
|
||||||
|
marker1 = Mock()
|
||||||
|
marker1.latitude = 30.521
|
||||||
|
marker1.longitude = 50.451
|
||||||
|
|
||||||
|
marker2 = Mock()
|
||||||
|
marker2.latitude = 30.524
|
||||||
|
marker2.longitude = 50.454
|
||||||
|
|
||||||
|
self.instance._active_markers = [marker1, marker2]
|
||||||
|
|
||||||
|
result = self.instance.map_lat_lon_to_processed_agent_data(50.452, 30.522)
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(result, marker1)
|
||||||
|
|
||||||
|
result = self.instance.map_lat_lon_to_processed_agent_data(50.453, 30.523)
|
||||||
|
self.assertIsNotNone(result)
|
||||||
|
self.assertEqual(result, marker2)
|
||||||
|
|
||||||
|
result = self.instance.map_lat_lon_to_processed_agent_data(50.459, 30.529)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_empty_markers(self):
|
def test_empty_markers(self):
|
||||||
self.instance._active_markers = []
|
self.instance._active_markers = []
|
||||||
|
|||||||
Reference in New Issue
Block a user