mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 23:18:03 -03:30
deal with a special null null case
This commit is contained in:
parent
2279e1e8dc
commit
f2846101a3
@ -207,7 +207,6 @@ class BaseAccess(object):
|
||||
'''
|
||||
new = None
|
||||
changed = True
|
||||
is_removal = False
|
||||
if data and 'reference_obj' in data:
|
||||
# Use reference object's related fields, if given
|
||||
new = getattr(data['reference_obj'], field)
|
||||
@ -218,7 +217,6 @@ class BaseAccess(object):
|
||||
new = raw_value
|
||||
elif raw_value is None:
|
||||
new = None
|
||||
is_removal = True
|
||||
else:
|
||||
try:
|
||||
new_pk = int(raw_value)
|
||||
@ -238,7 +236,7 @@ class BaseAccess(object):
|
||||
if obj and (changed or mandatory):
|
||||
current = getattr(obj, field)
|
||||
|
||||
if obj and new == current and (not is_removal):
|
||||
if obj and new == current:
|
||||
# Resource not changed, like a PUT request
|
||||
changed = False
|
||||
|
||||
|
||||
@ -101,6 +101,14 @@ class TestRelatedFieldAccess:
|
||||
assert not access.check_related(
|
||||
'related', mocker.MagicMock, data, obj=resource_bad)
|
||||
|
||||
def test_existing_not_null_null(self, access, bad_role, mocker):
|
||||
resource = mocker.MagicMock(related=None)
|
||||
data = {'related': None}
|
||||
# Not changing anything by giving null when it is already-null
|
||||
# important for PUT requests
|
||||
assert access.check_related(
|
||||
'related', mocker.MagicMock, data, obj=resource, mandatory=True)
|
||||
|
||||
@pytest.fixture
|
||||
def job_template_with_ids(job_template_factory):
|
||||
# Create non-persisted objects with IDs to send to job_template_factory
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user