Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.doom_launcher/mpks/com.micropythonos.doom_launcher_0.1.0.mpk",
"fullname": "com.micropythonos.doom_launcher",
"version": "0.1.0",
"category": "games",
"category": "games"
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"publisher": "MicroPythonOS",
"short_description": "ESPNow Chat",
"long_description": "Simple chat app using EspNow protocol for communication between devices.",
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.espnow_chat/icons/com.micropythonos.espnow_chat_0.0.1_64x64.png",
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.espnow_chat/mpks/com.micropythonos.espnow_chat_0.0.1.mpk",
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.espnow_chat/icons/com.micropythonos.espnow_chat_0.1.0_64x64.png",
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.espnow_chat/mpks/com.micropythonos.espnow_chat_0.1.0.mpk",
"fullname": "com.micropythonos.espnow_chat",
"version": "0.1.0",
"category": "development",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"publisher": "MicroPythonOS",
"short_description": "Scan Bluetooth",
"long_description": "Lists all nearby Bluetooth devices with some information",
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.scan_bluetooth/icons/com.micropythonos.scan_bluetooth_0.0.1_64x64.png",
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.scan_bluetooth/mpks/com.micropythonos.scan_bluetooth_0.0.1.mpk",
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.scan_bluetooth/icons/com.micropythonos.scan_bluetooth_0.1.0_64x64.png",
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.scan_bluetooth/mpks/com.micropythonos.scan_bluetooth_0.1.0.mpk",
"fullname": "com.micropythonos.scan_bluetooth",
"version": "0.1.0",
"category": "development",
Expand Down
102 changes: 102 additions & 0 deletions tests/test_apps_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import json
import unittest
from pathlib import Path

APPS_BASE_PATH = Path(__file__).parent.parent / "internal_filesystem" / "apps"


def iter_app_path():
for app in APPS_BASE_PATH.iterdir():
if app.is_dir():
yield app


class TestAppsManifest(unittest.TestCase):
def test_all_apps_manifest(self):
for app_path in iter_app_path():
with self.subTest(app=app_path.name):
manifest = app_path / "META-INF" / "MANIFEST.JSON"
self.assertTrue(manifest.is_file(), f"Missing {manifest=}")
try:
with manifest.open("r", encoding="utf-8") as f:
data = json.load(f)
except Exception as e:
self.fail(f"Invalid JSON in {manifest=}: {e}")

fullname = app_path.name
self.assertEqual(data.get("fullname"), fullname)

# Check name:
name = data.get("name")
self.assertTrue(name, f"Missing name in {manifest=}")

# Check version is a valid Version
version = data.get("version")
self.assertTrue(version, f"Missing version in {manifest=}")
try:
# Until we can use packaging.version.Version check canonical version manually:
version_tuple = tuple(int(x) for x in version.split("."))
version_str = ".".join(str(x) for x in version_tuple)
except Exception as e:
self.fail(f"Invalid version {version=} in {manifest=}: {e}")
self.assertEqual(
version_str,
version,
f"{version=} in {manifest=} is not in canonical form",
)

# Test download_url:
download_url = data.get("download_url")
self.assertTrue(download_url, f"Missing download_url in {manifest=}")
self.assertTrue(
download_url.startswith("https://apps.micropythonos.com/apps/"),
f"Invalid download_url in {manifest=}: {download_url}",
)
self.assertEqual(
download_url,
f"https://apps.micropythonos.com/apps/{fullname}/mpks/{fullname}_{version}.mpk",
)

# Test icon_url:
icon_url = data.get("icon_url")
self.assertTrue(icon_url, f"Missing icon_url in {manifest=}")
self.assertTrue(
icon_url.startswith("https://apps.micropythonos.com/apps/"),
f"Invalid icon_url in {manifest=}: {icon_url}",
)
self.assertEqual(
icon_url,
f"https://apps.micropythonos.com/apps/{fullname}/icons/{fullname}_{version}_64x64.png",
)

# Test activities.entrypoint
activities = data.get("activities", [])
for act in activities:
entrypoint = act.get("entrypoint")
self.assertTrue(
entrypoint, f"Missing entrypoint in activity of {manifest=}"
)
self.assertTrue(
entrypoint.endswith(".py"),
f"Invalid entrypoint in activity of {manifest=}: {entrypoint}",
)
entrypoint_path = app_path / entrypoint
self.assertTrue(
entrypoint_path.is_file(),
f"{entrypoint=} in {manifest=} does not exist as file",
)

classname = act.get("classname")
self.assertTrue(
classname, f"Missing classname in activity of {manifest=}"
)
entrypoint_code = entrypoint_path.read_text()
self.assertIn(
classname,
entrypoint_code,
f"{classname=} not found in {entrypoint=} of {manifest=}",
)


if __name__ == "__main__":
unittest.main()
Loading