Files
reelbox/server/tests/test_catalog_sync_units.py
T

39 lines
1.8 KiB
Python

"""Operational boundaries of the installed updater schedule."""
import configparser
from pathlib import Path
import unittest
SERVER = Path(__file__).resolve().parents[1]
class SyncUnitTests(unittest.TestCase):
def unit(self, name):
config = configparser.ConfigParser(interpolation=None, strict=False)
config.optionxform = str
config.read(SERVER / name)
return config
def test_timer_uses_three_day_interval_and_boot_catch_up(self):
timer = self.unit('reelbox-sync.timer')
self.assertEqual(timer['Timer']['OnUnitActiveSec'], '3d')
self.assertEqual(timer['Timer']['OnBootSec'], '15min')
self.assertEqual(timer['Timer']['Unit'], 'reelbox-sync.service')
self.assertNotIn('OnCalendar', timer['Timer'])
self.assertEqual(timer['Install']['WantedBy'], 'timers.target')
def test_updater_is_bounded_and_separate_from_public_api(self):
service = self.unit('reelbox-sync.service')['Service']
self.assertEqual(service['Type'], 'oneshot')
self.assertEqual(service['TimeoutStartSec'], '8h')
self.assertEqual(service['RestartSec'], '1h')
self.assertEqual(service['ProtectSystem'], 'strict')
self.assertEqual(service['ProtectHome'], 'true')
self.assertEqual(service['EnvironmentFile'], '/etc/reelbox/sync.env')
self.assertEqual(service['UMask'], '0077')
self.assertIn('catalog_sync_runner.py', service['ExecStart'])
self.assertEqual(service['ReadWritePaths'], '/var/lib/reelbox-api /var/lib/reelbox-sync')
api = self.unit('reelbox-api.service')['Service']
self.assertEqual(api['IPAddressDeny'], 'any')
self.assertEqual(api['IPAddressAllow'], 'localhost')
self.assertNotIn('sync.env', api.get('EnvironmentFile', ''))