Skip to content

Commit bf81ee4

Browse files
committed
Added test for 'notify' RSyncer class method
1 parent 6f16555 commit bf81ee4

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/client/test_rsync.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,42 @@ def test_rsyncer_status(
129129
)
130130

131131

132+
@pytest.mark.parametrize("notify", (True, False))
133+
def test_rsyncer_notify(
134+
mocker: MockerFixture,
135+
tmp_path: Path,
136+
mock_server_url: MagicMock,
137+
notify: bool,
138+
):
139+
# Patch the superclass that RSyncer stems from
140+
mock_notify = mocker.patch("murfey.client.rsync.Observer.notify")
141+
mock_notify.return_value = None
142+
143+
# Initialise the RSyncer
144+
rsyncer = RSyncer(
145+
basepath_local=tmp_path / "local",
146+
basepath_remote=tmp_path / "remote",
147+
rsync_module=mock.ANY,
148+
server_url=mock_server_url,
149+
notify=notify,
150+
)
151+
# Check that the 'notify' attribute is set correctly
152+
assert rsyncer._notify == notify
153+
154+
# Run 'notify' and check that the expected calls were made
155+
rsyncer.notify("arg1", "arg2", kwarg1="kwarg1", kwarg2="kwarg2")
156+
if notify:
157+
mock_notify.assert_called_once_with(
158+
"arg1",
159+
"arg2",
160+
secondary=False,
161+
kwarg1="kwarg1",
162+
kwarg2="kwarg2",
163+
)
164+
else:
165+
mock_notify.assert_not_called()
166+
167+
132168
@pytest.mark.parametrize("rsyncer_status", ("default", "is_alive", "stopping"))
133169
def test_rsyncer_start(
134170
tmp_path: Path,

0 commit comments

Comments
 (0)