mirror of
https://github.com/ansible/awx.git
synced 2026-07-31 01:49:56 -02:30
add tests
This commit is contained in:
@@ -12,3 +12,35 @@ def test_clean_credential_insights():
|
||||
proj.clean_credential()
|
||||
|
||||
assert json.dumps(str(e.value)) == json.dumps(str([u'Insights Credential is required for an Insights Project.']))
|
||||
|
||||
|
||||
class TestProjectCacheId:
|
||||
def test_cache_id_prefers_scm_revision(self):
|
||||
proj = Project(scm_revision='a6e2e68042e58cccfda35614ef84537d39690fcd')
|
||||
proj.current_job_id = 100
|
||||
proj.last_job_id = 99
|
||||
assert proj.cache_id == 'a6e2e68042e58cccfda35614ef84537d39690fcd'
|
||||
|
||||
def test_cache_id_falls_back_to_current_job_id(self):
|
||||
proj = Project(scm_revision='')
|
||||
proj.current_job_id = 100
|
||||
proj.last_job_id = 99
|
||||
assert proj.cache_id == '100'
|
||||
|
||||
def test_cache_id_falls_back_to_last_job_id(self):
|
||||
proj = Project(scm_revision='')
|
||||
proj.current_job_id = None
|
||||
proj.last_job_id = 99
|
||||
assert proj.cache_id == '99'
|
||||
|
||||
def test_cache_id_stable_across_different_last_job_ids(self):
|
||||
"""Simulates the multi-controller scenario: scm_revision stays the same
|
||||
even when last_job_id changes due to a sync on another node."""
|
||||
proj = Project(scm_revision='a6e2e68042e58cccfda35614ef84537d39690fcd')
|
||||
proj.last_job_id = 100
|
||||
cache_id_before = proj.cache_id
|
||||
|
||||
proj.last_job_id = 200
|
||||
cache_id_after = proj.cache_id
|
||||
|
||||
assert cache_id_before == cache_id_after
|
||||
|
||||
Reference in New Issue
Block a user