1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

allow smart inventory to be created

related to https://github.com/ansible/ansible-tower/issues/7261
This commit is contained in:
Chris Meyers 2017-07-24 10:48:03 -04:00
parent f175fbba23
commit eaddafc920
2 changed files with 7 additions and 1 deletions

View File

@ -370,7 +370,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin):
return self.groups.exclude(parents__pk__in=group_pks).distinct()
def clean_insights_credential(self):
if self.kind == 'smart':
if self.kind == 'smart' and self.insights_credential:
raise ValidationError(_("Assignment not allowed for Smart Inventory"))
if self.insights_credential and self.insights_credential.credential_type.kind != 'insights':
raise ValidationError(_("Credential kind must be 'insights'."))

View File

@ -64,6 +64,12 @@ def test_invalid_clean_insights_credential():
assert json.dumps(str(e.value)) == json.dumps(str([u"Credential kind must be 'insights'."]))
def test_valid_kind_clean_insights_credential():
inv = Inventory(kind='smart')
inv.clean_insights_credential()
def test_invalid_kind_clean_insights_credential():
cred_type = CredentialType.defaults['insights']()
insights_cred = Credential(credential_type=cred_type)