mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Hack to delete orphaned organizations, consolidate get_one methods
minor test update Updating the message if more than one object is found Update test to new message
This commit is contained in:
@@ -127,7 +127,9 @@ def test_missing_credential_type(run_module, admin_user, organization):
|
||||
state='present'
|
||||
), admin_user)
|
||||
assert result.get('failed', False), result
|
||||
assert 'foobar was not found on the Tower server' in result['msg']
|
||||
assert 'credential_type' in result['msg']
|
||||
assert 'foobar' in result['msg']
|
||||
assert 'returned 0 items, expected 1' in result['msg']
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
@@ -4,7 +4,7 @@ __metaclass__ = type
|
||||
import json
|
||||
import sys
|
||||
|
||||
from awx.main.models import Organization, Team
|
||||
from awx.main.models import Organization, Team, Project, Inventory
|
||||
from requests.models import Response
|
||||
from unittest import mock
|
||||
|
||||
@@ -125,3 +125,19 @@ def test_conflicting_name_and_id(run_module, admin_user):
|
||||
'Lookup by id should be preferenced over name in cases of conflict.'
|
||||
)
|
||||
assert team.organization.name == 'foo'
|
||||
|
||||
def test_multiple_lookup(run_module, admin_user):
|
||||
org1 = Organization.objects.create(name='foo')
|
||||
org2 = Organization.objects.create(name='bar')
|
||||
inv = Inventory.objects.create(name='Foo Inv')
|
||||
proj1 = Project.objects.create(name='foo', organization=org1, scm_type='git', scm_url="https://github.com/ansible/ansible-tower-samples",)
|
||||
proj2 = Project.objects.create(name='foo', organization=org2, scm_type='git', scm_url="https://github.com/ansible/ansible-tower-samples",)
|
||||
result = run_module('tower_job_template', {
|
||||
'name': 'Demo Job Template', 'project': proj1.name, 'inventory': inv.id, 'playbook': 'hello_world.yml'
|
||||
}, admin_user)
|
||||
assert result.get('failed', False)
|
||||
assert 'projects' in result['msg']
|
||||
assert 'foo' in result['msg']
|
||||
assert 'returned 2 items, expected 1' in result['msg']
|
||||
assert 'query' in result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user