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

@@ -7,20 +7,31 @@ from awx.main.models import Organization
@pytest.mark.django_db
def test_create_organization(run_module, admin_user):
def test_create_organization(run_converted_module, admin_user):
module_args = {'name': 'foo', 'description': 'barfoo', 'state': 'present'}
module_args = {
'name': 'foo',
'description': 'barfoo',
'state': 'present',
'max_hosts': '0',
'tower_host': None,
'tower_username': None,
'tower_password': None,
'validate_certs': None,
'tower_oauthtoken': None,
'tower_config_file': None,
'custom_virtualenv': None
}
result = run_module('tower_organization', module_args, admin_user)
result = run_converted_module('tower_organization', module_args, admin_user)
assert result.get('changed'), result
org = Organization.objects.get(name='foo')
assert result == {
"organization": "foo",
"state": "present",
"id": org.id,
"changed": True,
"name": "foo",
"id": org.id,
"invocation": {
"module_args": module_args
}
@@ -30,10 +41,10 @@ def test_create_organization(run_module, admin_user):
@pytest.mark.django_db
def test_create_organization_with_venv(run_module, admin_user, mocker):
def test_create_organization_with_venv(run_converted_module, admin_user, mocker):
path = '/var/lib/awx/venv/custom-venv/foobar13489435/'
with mocker.patch('awx.main.models.mixins.get_custom_venv_choices', return_value=[path]):
result = run_module('tower_organization', {
result = run_converted_module('tower_organization', {
'name': 'foo',
'custom_virtualenv': path,
'state': 'present'
@@ -44,8 +55,7 @@ def test_create_organization_with_venv(run_module, admin_user, mocker):
result.pop('invocation')
assert result == {
"organization": "foo",
"state": "present",
"name": "foo",
"id": org.id
}