mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 12:41:19 -03:30
normalize custom_virtualenv empty values to null
see: https://github.com/ansible/ansible-tower/issues/7923
This commit is contained in:
parent
1596b2907b
commit
8955e6bc1c
@ -441,4 +441,6 @@ class CustomVirtualEnvMixin(models.Model):
|
||||
raise ValidationError(
|
||||
_('{} is not a valid virtualenv in {}').format(value, settings.BASE_VENV_PATH)
|
||||
)
|
||||
return os.path.join(value or '', '')
|
||||
if value:
|
||||
return os.path.join(value, '')
|
||||
return None
|
||||
|
||||
@ -602,3 +602,16 @@ def test_job_template_invalid_custom_virtualenv(get, patch, organization_factory
|
||||
assert resp.data['custom_virtualenv'] == [
|
||||
'/foo/bar is not a valid virtualenv in {}'.format(settings.BASE_VENV_PATH)
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('value', ["", None])
|
||||
def test_job_template_unset_custom_virtualenv(get, patch, organization_factory,
|
||||
job_template_factory, value):
|
||||
objs = organization_factory("org", superusers=['admin'])
|
||||
jt = job_template_factory("jt", organization=objs.organization,
|
||||
inventory='test_inv', project='test_proj').job_template
|
||||
|
||||
url = reverse('api:job_template_detail', kwargs={'pk': jt.id})
|
||||
resp = patch(url, {'custom_virtualenv': value}, user=objs.superusers.admin, expect=200)
|
||||
assert resp.data['custom_virtualenv'] is None
|
||||
|
||||
@ -207,3 +207,11 @@ def test_organization_invalid_custom_virtualenv(get, patch, organization, admin)
|
||||
assert resp.data['custom_virtualenv'] == [
|
||||
'/foo/bar is not a valid virtualenv in {}'.format(settings.BASE_VENV_PATH)
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('value', ["", None])
|
||||
def test_organization_unset_custom_virtualenv(get, patch, organization, admin, value):
|
||||
url = reverse('api:organization_detail', kwargs={'pk': organization.id})
|
||||
resp = patch(url, {'custom_virtualenv': value}, user=admin, expect=200)
|
||||
assert resp.data['custom_virtualenv'] is None
|
||||
|
||||
@ -36,3 +36,11 @@ def test_project_invalid_custom_virtualenv(get, patch, project, admin):
|
||||
assert resp.data['custom_virtualenv'] == [
|
||||
'/foo/bar is not a valid virtualenv in {}'.format(settings.BASE_VENV_PATH)
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize('value', ["", None])
|
||||
def test_project_unset_custom_virtualenv(get, patch, project, admin, value):
|
||||
url = reverse('api:project_detail', kwargs={'pk': project.id})
|
||||
resp = patch(url, {'custom_virtualenv': value}, user=admin, expect=200)
|
||||
assert resp.data['custom_virtualenv'] is None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user