mirror of
https://github.com/ansible/awx.git
synced 2026-05-21 07:47:44 -02:30
Further module conversion changes, unit test changes
Multiple module changes Added on_change callback Added head_endpoint Added additional error returns Respond with a try an ID message if multiple assets found by name via return_none_on_404 kwarg Diferentiated between login and logout token errors Added is_job_done method
This commit is contained in:
66
awx_collection/test/awx/test_team.py
Normal file
66
awx_collection/test/awx/test_team.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from awx.main.models import Organization, Team
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_create_team(run_converted_module, admin_user):
|
||||
org = Organization.objects.create(name='foo')
|
||||
|
||||
result = run_converted_module('tower_team', {
|
||||
'name': 'foo_team',
|
||||
'description': 'fooin around',
|
||||
'state': 'present',
|
||||
'organization': 'foo'
|
||||
}, admin_user)
|
||||
|
||||
team = Team.objects.filter(name='foo_team').first()
|
||||
|
||||
result.pop('invocation')
|
||||
assert result == {
|
||||
"changed": True,
|
||||
"name": "foo_team",
|
||||
"id": team.id if team else None,
|
||||
}
|
||||
team = Team.objects.get(name='foo_team')
|
||||
assert team.description == 'fooin around'
|
||||
assert team.organization_id == org.id
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_modify_team(run_converted_module, admin_user):
|
||||
org = Organization.objects.create(name='foo')
|
||||
team = Team.objects.create(
|
||||
name='foo_team',
|
||||
organization=org,
|
||||
description='flat foo'
|
||||
)
|
||||
assert team.description == 'flat foo'
|
||||
|
||||
result = run_converted_module('tower_team', {
|
||||
'name': 'foo_team',
|
||||
'description': 'fooin around',
|
||||
'organization': 'foo'
|
||||
}, admin_user)
|
||||
team.refresh_from_db()
|
||||
result.pop('invocation')
|
||||
assert result == {
|
||||
"id": team.id,
|
||||
"changed": True
|
||||
}
|
||||
assert team.description == 'fooin around'
|
||||
|
||||
# 2nd modification, should cause no change
|
||||
result = run_converted_module('tower_team', {
|
||||
'name': 'foo_team',
|
||||
'description': 'fooin around',
|
||||
'organization': 'foo'
|
||||
}, admin_user)
|
||||
result.pop('invocation')
|
||||
assert result == {
|
||||
"id": team.id,
|
||||
"changed": False
|
||||
}
|
||||
Reference in New Issue
Block a user