Skip to content

Commit

Permalink
fix timer and integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
aciba90 committed Feb 6, 2023
1 parent d79ecec commit 66f9c84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions features/attach_validtoken.feature
Expand Up @@ -398,9 +398,11 @@ Feature: Command behaviour when attaching a machine to an Ubuntu Pro
"""
And I append the following on uaclient config:
"""
update_contract_info_timer: 0
features:
machine_token_overlay: "/tmp/machine-token-overlay.json"
"""
And I run `python3 /usr/lib/ubuntu-advantage/timer.py` with sudo
When I run `pro status` with sudo
Then stdout matches regexp:
"""
Expand Down
6 changes: 6 additions & 0 deletions lib/timer.py
Expand Up @@ -161,6 +161,12 @@ def run_jobs(cfg: UAConfig, current_time: datetime):
jobs_status_obj.update_messaging = run_job(
cfg, update_message_job, current_time, jobs_status_obj.update_messaging
)
jobs_status_obj.update_contract_info = run_job(
cfg,
update_contract_info_job,
current_time,
jobs_status_obj.update_contract_info,
)
timer_jobs_state_file.write(jobs_status_obj)


Expand Down
8 changes: 6 additions & 2 deletions uaclient/tests/test_ua_timer.py
Expand Up @@ -106,7 +106,9 @@ def test_run_jobs_persists_job_status_on_successful_run(
m_job_status.next_run = next_run

fake_file.read.return_value = mock.MagicMock(
metering=m_job_status, update_messaging=None
metering=m_job_status,
update_messaging=None,
update_contract_info=None,
)
expected_next_run = now + datetime.timedelta(seconds=43200)

Expand All @@ -133,7 +135,9 @@ def test_run_job_ignores_late_next_run(self, FakeConfig):
next_run=now + datetime.timedelta(seconds=14400), last_run=None
)
fake_file.read.return_value = mock.MagicMock(
metering=m_job_status, update_messaging=None
metering=m_job_status,
update_messaging=None,
update_contract_info=None,
)

m_job_func = mock.Mock()
Expand Down

0 comments on commit 66f9c84

Please sign in to comment.