diff --git a/MapView/datasource.py b/MapView/datasource.py index 29cf19e..8262eb0 100644 --- a/MapView/datasource.py +++ b/MapView/datasource.py @@ -39,7 +39,11 @@ class Datasource: self.connection_status = None self._new_points = [] self._active_markers = [] - asyncio.ensure_future(self.connect_to_server()) + + try: + asyncio.ensure_future(self.connect_to_server()) + except RuntimeError: + Logger.info("No event loop detected, running in offline mode") def get_new_points(self): Logger.debug(self._new_points) diff --git a/MapView/tests/test_mp.py b/MapView/tests/test_mp.py index fab62f5..af93bf9 100644 --- a/MapView/tests/test_mp.py +++ b/MapView/tests/test_mp.py @@ -3,7 +3,6 @@ import sys from unittest.mock import Mock sys.modules['lineMapLayer'] = Mock() -sys.modules['datasource'] = Mock() sys.modules['config'] = Mock() from MapView.main import get_lat_lon, MapViewApp @@ -79,6 +78,7 @@ class TestMapLatLonToProcessedAgentData(unittest.TestCase): result = self.instance.map_lat_lon_to_processed_agent_data(50.45, 30.52) self.assertIsNotNone(result) + self.assertEqual(result, marker) def test_empty_markers(self): self.instance._active_markers = []