Skip to content

Commit

Permalink
Add first test for VM polling
Browse files Browse the repository at this point in the history
  • Loading branch information
eloquence committed Apr 15, 2020
1 parent 47c6a3c commit 3de355f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions launcher/tests/test_updater.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import pytest
import time
import subprocess
from importlib.machinery import SourceFileLoader
from datetime import datetime, timedelta
Expand Down Expand Up @@ -504,6 +505,24 @@ def test_apply_updates_dom0_failure(mocked_info, mocked_error, mocked_call):
mocked_error.assert_has_calls(error_log)


@mock.patch("Updater.sdlog.error")
@mock.patch("Updater.sdlog.info")
def test_vm_polling(mocked_info, mocked_error):
def mock_api(results):
for r in results:
yield r
time.sleep(0.1)

with mock.patch("Updater.qubes") as mocked_qubes:
mocked_qubes.domains = {"sys-net": mock.MagicMock()}
mocked_qubes.domains["sys-net"].is_running = mock.MagicMock(
side_effect=mock_api((True, True, False))
)
assert updater._wait_for_is_running("sys-net", False, timeout=1) is True
assert mocked_info.called
assert not mocked_error.called


@pytest.mark.parametrize("vm", current_templates.keys())
@mock.patch("subprocess.check_call", side_effect="0")
@mock.patch("Updater.sdlog.error")
Expand Down

0 comments on commit 3de355f

Please sign in to comment.