Files
computer-playbook/tests/unit/python/roles/web-app-nextcloud/test_server_id.py
T
kevinveenbirkenbachandClaude Opus 5.5 5e8890d208 Merge branch 'feature/updater' into feature/store-i18n
Brings in feature/updater accb22da75, which carries main 5995766f58.

Conflict resolutions:
- web-app-fider: main's tenant bootstrap (01_tenant.yml) runs first on
  the stack host, OIDC setup moves to 02_setup_oidc.yml, design to
  03_design.yml; flat includes so main's gate test reads them.
- sys-front-tls test_nginx_ssl_header: the tls fake maps the domain term
  store-i18n passes back to its app.
- group_vars 04_webserver.yml, sys-svc-proxy CSP header: store-i18n's
  webserver_resource lookup plus #1256's WEBSERVER_SECURITY_HEADERS and
  the security_headers.lua include after the CSP block.
- web-app-nextcloud: updater's decoupled Talk stack (Janus, signaling,
  NATS, recording builds) replaces aio-talk; store-i18n's per-network
  Talk backends move from the wrapper script into signaling.conf.j2 urls
  (NEXTCLOUD_HPB_SIGNALING_BACKEND_URLS from network_urls, canonical
  first); IS_COMPOSE_MODE/IS_SWARM_MODE booleans kept; the integration
  OpenProject digest stays delegated to STACK_HOST.
- users lookup docs, token-store write_many, cache README, meta info
  lint: both sides combined.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 00:40:05 +01:00

41 lines
1.3 KiB
Python

from __future__ import annotations
import unittest
from jinja2 import Environment, select_autoescape
from utils.cache.files import PROJECT_ROOT, read_text
from utils.cache.yaml import load_yaml_str
from utils.roles.mapping import ROLE_FILE_TEMPL_COMPOSE
TEMPLATE = read_text(
str(PROJECT_ROOT / "roles/web-app-nextcloud" / ROLE_FILE_TEMPL_COMPOSE)
)
def _environment(deployment_mode: str) -> dict:
start = TEMPLATE.index(" environment:\n")
end = TEMPLATE.index(" sysctls:", start)
rendered = (
Environment(autoescape=select_autoescape(default_for_string=False))
.from_string(TEMPLATE[start:end])
.render(IS_SWARM_MODE=deployment_mode == "swarm")
)
return load_yaml_str(rendered)["environment"]
class TestServerId(unittest.TestCase):
def test_compose_pins_a_server_id_nextcloud_accepts(self):
server_id = int(_environment("compose")["NC_serverid"])
self.assertGreaterEqual(server_id, 1)
self.assertLessEqual(server_id, 511)
def test_swarm_gives_every_replica_its_task_slot(self):
environment = _environment("swarm")
self.assertEqual(environment["NC_serverid"], "{{.Task.Slot}}")
self.assertEqual(environment["TASK_SLOT"], "{{.Task.Slot}}")
if __name__ == "__main__":
unittest.main()