Api issue float (#11757)

* Fix integer/float errors in survey

* Add SURVEY_TYPE_MAPPING to constants

Add SURVEY_TYPE_MAPPING to constants, and replace usage in a couple of
files.

Co-authored-by: Alexander Komarov <akomarov.me@gmail.com>
This commit is contained in:
Kersom
2022-03-04 14:03:17 -05:00
committed by GitHub
parent 0eac63b844
commit c6209df1e0
3 changed files with 38 additions and 6 deletions

View File

@@ -59,6 +59,38 @@ class SurveyVariableValidation:
assert accepted == {}
assert str(errors[0]) == "Value 5 for 'a' expected to be a string."
def test_job_template_survey_default_variable_validation(self, job_template_factory):
objects = job_template_factory(
"survey_variable_validation",
organization="org1",
inventory="inventory1",
credential="cred1",
persisted=False,
)
obj = objects.job_template
obj.survey_spec = {
"description": "",
"spec": [
{
"required": True,
"min": 0,
"default": "2",
"max": 1024,
"question_description": "",
"choices": "",
"variable": "a",
"question_name": "float_number",
"type": "float",
}
],
"name": "",
}
obj.survey_enabled = True
accepted, _, errors = obj.accept_or_ignore_variables({"a": 2})
assert accepted == {{"a": 2.0}}
assert not errors
@pytest.fixture
def job(mocker):