Files
one-os-dev-wayland-html5-co…/tests/test_compositor_app.py
T
1b-agent 93a5a0a221 Initial commit: one_os_compositor Odoo 20 addon — core OWL library + backend models + JWT auth
Includes:
- compositor.app, compositor.session, compositor.session.app, compositor.audit.log models
- /web/compositor/{token,apps,launch,audit} HTTP controllers with JWT (HS256)
- CompositorService OWL service (reusable via useService('compositor'))
- CompositorCanvas OWL component (reusable canvas wrapper)
- Security: compositor_group_user, compositor_group_manager groups + ir.access.csv rules
- 5 demo apps pre-loaded (gnome-calculator, xterm, gtk4-demo, glxgears, featherpad)
- Audit log capturing JWT issuance + app launch events
- Stub mode: launching apps returns a stub SurfaceHandle when proxy isn't connected
- Tested against Odoo 20 + PostgreSQL 17

Author: 1bspace.com
Parent company: 1B Global
License: Proprietary (1B Space internal use)
2026-10-08 08:48:46 +00:00

60 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
"""Tests for compositor.app model."""
from odoo.exceptions import ValidationError, AccessError
from odoo.tests import common, tagged
@tagged("post_install", "-at_install")
class TestCompositorApp(common.TransactionCase):
def setUp(self):
super().setUp()
self.App = self.env["compositor.app"]
self.group_user = self.env.ref("base.group_user")
self.group_manager = self.env.ref("one_os_compositor.compositor_group_manager")
def test_create_app_minimal(self):
app = self.App.create({
"name": "Test App",
"app_id": "test-app",
"executable": "/bin/true",
})
self.assertEqual(app.memory_limit_mb, 1024)
self.assertEqual(app.cpu_quota_percent, 200)
self.assertEqual(app.tasks_max, 256)
self.assertTrue(app.sandbox_gpu)
self.assertFalse(app.sandbox_network)
def test_app_id_unique(self):
self.App.create({"name": "App 1", "app_id": "duplicate", "executable": "/bin/true"})
with self.assertRaises(ValidationError):
self.App.create({"name": "App 2", "app_id": "duplicate", "executable": "/bin/true"})
def test_memory_limit_too_low(self):
with self.assertRaises(ValidationError):
self.App.create({
"name": "Bad App", "app_id": "bad-app",
"executable": "/bin/true", "memory_limit_mb": 32,
})
def test_get_launch_config(self):
app = self.App.create({
"name": "Test", "app_id": "test",
"executable": "/usr/bin/test",
"args": "--foo --bar",
"env_vars": "GDK_SCALE=1\n# comment\nGTK_DEBUG=all",
"memory_limit_mb": 512,
"cpu_quota_percent": 100,
"tasks_max": 64,
"sandbox_network": True,
"sandbox_gpu": False,
})
config = app.get_launch_config()
self.assertEqual(config["app_id"], "test")
self.assertEqual(config["executable"], "/usr/bin/test")
self.assertEqual(config["args"], "--foo --bar")
self.assertEqual(config["env"], {"GDK_SCALE": "1", "GTK_DEBUG": "all"})
self.assertEqual(config["memory_limit_mb"], 512)
self.assertTrue(config["sandbox_network"])
self.assertFalse(config["sandbox_gpu"])