Add device-bound robot notifications and automatic OAuth cards
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
spec=importlib.util.spec_from_file_location('notification_installer',ROOT/'scripts/apply_notification_client.py')
|
||||
installer=importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(installer)
|
||||
|
||||
|
||||
def test_client_patch_preserves_other_fixes_and_is_repeatable(tmp_path):
|
||||
baseline=ROOT.parent/'host-code/relay'
|
||||
marker='\n# Existing TLS and cloud-document fixes must stay.\n'
|
||||
for name in ['work_client.py','work_tools.py']:
|
||||
(tmp_path/name).write_text((baseline/name).read_text(encoding='utf-8')+marker,encoding='utf-8')
|
||||
updates=installer.prepare(tmp_path)
|
||||
assert all(marker in updates[name] for name in ['work_client.py','work_tools.py'])
|
||||
installer.apply(tmp_path)
|
||||
assert (tmp_path/'work_client.py').read_text(encoding='utf-8').count('notify_authorization(self, data)')==2
|
||||
assert (tmp_path/'work_tools.py').read_text(encoding='utf-8').count('register_notification_tool(directory)')==1
|
||||
again=installer.prepare(tmp_path)
|
||||
assert again['work_client.py']==(tmp_path/'work_client.py').read_text(encoding='utf-8')
|
||||
|
||||
|
||||
def test_unknown_client_version_is_not_modified(tmp_path):
|
||||
for name in ['work_client.py','work_tools.py']:(tmp_path/name).write_text('# unknown version\n')
|
||||
with pytest.raises(ValueError):installer.prepare(tmp_path)
|
||||
assert (tmp_path/'work_client.py').read_text()=='# unknown version\n'
|
||||
Reference in New Issue
Block a user