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:
beeankha
2020-01-24 11:30:16 -05:00
parent 68926dad27
commit 7c0ad461a5
10 changed files with 224 additions and 47 deletions

View 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
}