Initial server source import
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import pathlib
|
||||
import re
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
DOCS = ROOT / 'docs'
|
||||
|
||||
|
||||
class WorkerDocumentationTests(unittest.TestCase):
|
||||
def test_active_guides_have_platform_cheatsheets_without_cap_zero(self):
|
||||
paths = [
|
||||
DOCS / 'remote-worker-quickstart-ru.md',
|
||||
DOCS / 'remote-worker-operations.md',
|
||||
*(DOCS / f'remote-worker-cheatsheet-{name}-ru.md'
|
||||
for name in ('windows', 'linux', 'docker')),
|
||||
]
|
||||
for path in paths:
|
||||
content = path.read_text(encoding='utf-8')
|
||||
self.assertNotRegex(content, re.compile(r'cap\s*`?0`?', re.IGNORECASE), path)
|
||||
self.assertNotIn('--token', content, path)
|
||||
|
||||
def test_each_cheatsheet_covers_the_verified_lifecycle(self):
|
||||
expected = {
|
||||
'windows': ('.\\truf-worker.cmd start', '.\\truf-worker.cmd stop',
|
||||
'.\\truf-worker.cmd attach', '.\\truf-worker.cmd status',
|
||||
'.\\truf-worker.cmd watch'),
|
||||
'linux': ('./truf-worker start', './truf-worker stop',
|
||||
'./truf-worker attach', './truf-worker status',
|
||||
'./truf-worker watch'),
|
||||
'docker': ('docker compose up -d', 'workerctl.sh stop',
|
||||
'workerctl.sh attach', 'workerctl.sh status',
|
||||
'workerctl.sh watch'),
|
||||
}
|
||||
for name, commands in expected.items():
|
||||
content = (DOCS / f'remote-worker-cheatsheet-{name}-ru.md').read_text(
|
||||
encoding='utf-8',
|
||||
)
|
||||
self.assertIn('install --config', content)
|
||||
for command in commands:
|
||||
self.assertIn(command, content, f'{name}: {command}')
|
||||
|
||||
def test_general_guide_links_every_existing_platform_sheet(self):
|
||||
content = (DOCS / 'remote-worker-quickstart-ru.md').read_text(encoding='utf-8')
|
||||
for name in ('windows', 'linux', 'docker'):
|
||||
filename = f'remote-worker-cheatsheet-{name}-ru.md'
|
||||
self.assertIn(filename, content)
|
||||
self.assertTrue((DOCS / filename).is_file())
|
||||
|
||||
def test_docker_helpers_use_the_packaged_linux_launcher(self):
|
||||
shell = (ROOT / 'deploy' / 'worker' / 'workerctl.sh').read_text(encoding='ascii')
|
||||
powershell = (ROOT / 'deploy' / 'worker' / 'workerctl.ps1').read_text(
|
||||
encoding='ascii',
|
||||
)
|
||||
self.assertIn('/opt/truf-worker/truf-worker', shell)
|
||||
self.assertIn('/opt/truf-worker/truf-worker', powershell)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user