mirror of
https://github.com/yellowcooln/meshcore-mqtt-live-map.git
synced 2026-04-20 23:23:36 +00:00
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
import asyncio
|
|
import os
|
|
|
|
import pytest
|
|
|
|
import app
|
|
|
|
|
|
LEGACY_COVERAGE_URL_ENV = "TEST_LEGACY_COVERAGE_URL"
|
|
MESHMAPPER_COVERAGE_URL_ENV = "TEST_MESHMAPPER_COVERAGE_URL"
|
|
MESHMAPPER_COVERAGE_KEY_ENV = "TEST_MESHMAPPER_COVERAGE_KEY"
|
|
|
|
|
|
def test_live_legacy_coverage_map():
|
|
coverage_url = os.getenv(LEGACY_COVERAGE_URL_ENV, "").strip()
|
|
if not coverage_url:
|
|
pytest.skip(f"{LEGACY_COVERAGE_URL_ENV} is not set")
|
|
|
|
samples, provider = asyncio.run(
|
|
app._fetch_coverage_upstream_for_test(coverage_url, "")
|
|
)
|
|
|
|
assert provider == "legacy"
|
|
assert isinstance(samples, list)
|
|
assert len(samples) > 0
|
|
first = samples[0]
|
|
assert isinstance(first, dict)
|
|
assert any(key in first for key in ("hash", "name", "id"))
|
|
|
|
|
|
def test_live_meshmapper_coverage_map():
|
|
coverage_url = os.getenv(MESHMAPPER_COVERAGE_URL_ENV, "").strip()
|
|
api_key = os.getenv(MESHMAPPER_COVERAGE_KEY_ENV, "").strip()
|
|
if not coverage_url:
|
|
pytest.skip(f"{MESHMAPPER_COVERAGE_URL_ENV} is not set")
|
|
if not api_key:
|
|
pytest.skip(f"{MESHMAPPER_COVERAGE_KEY_ENV} is not set")
|
|
|
|
samples, provider = asyncio.run(
|
|
app._fetch_coverage_upstream_for_test(coverage_url, api_key)
|
|
)
|
|
|
|
assert provider == "meshmapper"
|
|
assert isinstance(samples, list)
|
|
assert len(samples) > 0
|
|
first = samples[0]
|
|
assert isinstance(first, dict)
|
|
assert "bounds" in first
|
|
assert "fill_color" in first
|