mirror of
https://github.com/ansible/awx.git
synced 2026-11-22 16:26:10 -03:30
Merge branch 'devel' of github.com:ansible/ansible-tower into 11th-hour
This commit is contained in:
@@ -28,6 +28,7 @@ from awx.main.models.credential import Credential
|
||||
from awx.main.models.jobs import JobTemplate
|
||||
from awx.main.models.inventory import (
|
||||
Group,
|
||||
Inventory,
|
||||
)
|
||||
from awx.main.models.organization import (
|
||||
Organization,
|
||||
@@ -175,6 +176,16 @@ def machine_credential():
|
||||
def inventory(organization):
|
||||
return organization.inventories.create(name="test-inv")
|
||||
|
||||
@pytest.fixture
|
||||
def inventory_factory(organization):
|
||||
def factory(name, org=organization):
|
||||
try:
|
||||
inv = Inventory.objects.get(name=name, organization=org)
|
||||
except Inventory.DoesNotExist:
|
||||
inv = Inventory.objects.create(name=name, organization=org)
|
||||
return inv
|
||||
return factory
|
||||
|
||||
@pytest.fixture
|
||||
def label(organization):
|
||||
return organization.labels.create(name="test-label", description="test-label-desc")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
from awx.main.models import Job
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_job_blocking(get, post, job_template, inventory, inventory_factory):
|
||||
j1 = Job.objects.create(job_template=job_template,
|
||||
inventory=inventory)
|
||||
j2 = Job.objects.create(job_template=job_template,
|
||||
inventory=inventory)
|
||||
assert j1.is_blocked_by(j2)
|
||||
j2.inventory = inventory_factory(name='test-different-inventory')
|
||||
assert not j1.is_blocked_by(j2)
|
||||
j_callback_1 = Job.objects.create(job_template=job_template,
|
||||
inventory=inventory,
|
||||
launch_type='callback',
|
||||
limit='a')
|
||||
j_callback_2 = Job.objects.create(job_template=job_template,
|
||||
inventory=inventory,
|
||||
launch_type='callback',
|
||||
limit='a')
|
||||
assert j_callback_1.is_blocked_by(j_callback_2)
|
||||
j_callback_2.limit = 'b'
|
||||
assert not j_callback_1.is_blocked_by(j_callback_2)
|
||||
Reference in New Issue
Block a user