44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
from k1link.fleet.router_notifications import publish_router_results
|
|
from k1link.notifications import NotificationHistory
|
|
|
|
|
|
def test_outcome_is_durable_once_and_independent_of_open_windows(tmp_path):
|
|
history = NotificationHistory(tmp_path)
|
|
row = dict(id='rover', node_id='node', name='Test', binding={'binding_id': 'bound'})
|
|
entry = dict(binding='bound', public=dict(operation_id='one', action='policy', state='queued'))
|
|
pending = {('rover', 'one'): entry}
|
|
for state in ['queued', 'applying']:
|
|
entry['public']['state'] = state
|
|
publish_router_results(history, row, pending)
|
|
assert history.listing()['items'] == []
|
|
entry['public'].update(state='error', error='router_busy')
|
|
publish_router_results(history, row, pending)
|
|
publish_router_results(history, row, pending)
|
|
messages = history.listing()['items']
|
|
assert len(messages) == 1 and messages[0]['tone'] == 'error'
|
|
assert 'занят' in messages[0]['description']
|
|
del entry['notified_state']
|
|
publish_router_results(NotificationHistory(tmp_path), row, pending)
|
|
assert len(history.listing()['items']) == 1
|
|
|
|
|
|
def test_scope_is_operator_policy_and_late_confirmation_updates_uncertainty(tmp_path):
|
|
history = NotificationHistory(tmp_path)
|
|
history.configure('router.applied', True)
|
|
row = dict(id='rover', node_id='node', name='Test', binding={'binding_id': 'bound'})
|
|
entry = dict(binding='bound', public=dict(operation_id='one', action='policy', state='unknown'))
|
|
pending = {
|
|
('other', 'one'): entry.copy(),
|
|
('rover', 'old'): {**entry, 'binding': 'old'},
|
|
('rover', 'inspect'): {**entry, 'public': {'action': 'inspect', 'state': 'complete'}},
|
|
('rover', 'one'): entry,
|
|
}
|
|
publish_router_results(history, row, pending)
|
|
assert len(history.listing()['items']) == 1
|
|
assert history.listing()['items'][0]['tone'] == 'warning'
|
|
entry['public']['state'] = 'complete'
|
|
publish_router_results(history, row, pending)
|
|
messages = history.listing()['items']
|
|
assert len(messages) == 2 and messages[0]['tone'] == 'success'
|
|
assert 'Фактический канал' in messages[0]['description']
|