mirror of
https://github.com/ansible/awx.git
synced 2026-06-24 16:17:51 -02:30
Add WorkflowJob.instance_groups and distinguish from char_prompts
This removes a loop that ran on import the loop was giving the wrong behavior and it initialized too many fields as char_prompts fields With this, we will now enumerate the char_prompts type fields manually
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import pytest
|
||||
|
||||
# AWX
|
||||
from awx.main.models import JobTemplate, JobLaunchConfig, ExecutionEnvironment
|
||||
from awx.main.models.jobs import JobTemplate, JobLaunchConfig, LaunchTimeConfigBase
|
||||
from awx.main.models.execution_environments import ExecutionEnvironment
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -75,3 +76,28 @@ class TestConfigReversibility:
|
||||
print(prompts)
|
||||
print(config.prompts_dict())
|
||||
assert config.prompts_dict() == prompts
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestLaunchConfigModels:
|
||||
def get_concrete_subclasses(self, cls):
|
||||
r = []
|
||||
for c in cls.__subclasses__():
|
||||
if c._meta.abstract:
|
||||
r.extend(self.get_concrete_subclasses(c))
|
||||
else:
|
||||
r.append(c)
|
||||
return r
|
||||
|
||||
def test_non_job_config_complete(self):
|
||||
"""This performs model validation which replaces code that used run on import."""
|
||||
for field_name in JobTemplate.get_ask_mapping().keys():
|
||||
if field_name in LaunchTimeConfigBase.SUBCLASS_FIELDS:
|
||||
assert not hasattr(LaunchTimeConfigBase, field_name)
|
||||
else:
|
||||
assert hasattr(LaunchTimeConfigBase, field_name)
|
||||
|
||||
def test_subclass_fields_complete(self):
|
||||
for cls in self.get_concrete_subclasses(LaunchTimeConfigBase):
|
||||
for field_name in LaunchTimeConfigBase.SUBCLASS_FIELDS:
|
||||
assert hasattr(cls, field_name)
|
||||
|
||||
Reference in New Issue
Block a user