Skip to content

Commit ae65400

Browse files
committed
tests: add update parameter to subscription
Modify 2 subscriptions to test the update parameter. The module_change_cb is called on sysrepo update events. Signed-off-by: Jeremie Leska <[email protected]>
1 parent 28ee073 commit ae65400

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Diff for: tests/test_subs_module_change.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ def test_module_change_sub(self):
4545
expected_changes = []
4646

4747
def module_change_cb(event, req_id, changes, private_data):
48-
self.assertIn(event, ("change", "done", "abort"))
48+
self.assertIn(event, ("change", "done", "abort", "update"))
4949
self.assertIs(private_data, priv)
5050
for c in changes:
5151
if c.xpath == "/sysrepo-example:conf/system/hostname":
5252
if event == "change" and c.value == "INVALID":
5353
raise sysrepo.SysrepoValidationFailedError("invalid hostname")
54-
if event in ("change", "done"):
54+
if event in ("change", "done", "update"):
5555
self.assertEqual(changes, expected_changes)
5656
if event == "done":
5757
sysrepo.update_config_cache(current_config, changes)
@@ -61,6 +61,7 @@ def module_change_cb(event, req_id, changes, private_data):
6161
"/sysrepo-example:conf",
6262
module_change_cb,
6363
private_data=priv,
64+
update=True,
6465
)
6566

6667
with self.conn.start_session("running") as ch_sess:
@@ -316,15 +317,15 @@ def test_module_change_sub_unsafe(self):
316317

317318
def module_change_cb(session, event, req_id, private_data):
318319
self.assertIsInstance(session, SysrepoSession)
319-
self.assertIn(event, ("change", "done", "abort"))
320+
self.assertIn(event, ("change", "done", "abort", "update"))
320321
self.assertIsInstance(req_id, int)
321322
self.assertIs(private_data, priv)
322323
changes = list(session.get_changes("/sysrepo-example:conf//."))
323324
for c in changes:
324325
if c.xpath == "/sysrepo-example:conf/system/hostname":
325326
if event == "change" and c.value == "INVALID":
326327
raise sysrepo.SysrepoValidationFailedError("invalid hostname")
327-
if event in ("change", "done"):
328+
if event in ("change", "done", "update"):
328329
self.assertEqual(changes, expected_changes)
329330
if event == "done":
330331
sysrepo.update_config_cache(current_config, changes)
@@ -334,6 +335,7 @@ def module_change_cb(session, event, req_id, private_data):
334335
"/sysrepo-example:conf",
335336
module_change_cb,
336337
private_data=priv,
338+
update=True,
337339
)
338340

339341
with self.conn.start_session("running") as ch_sess:

0 commit comments

Comments
 (0)