Fix the tests to conform to the new Insights results

This commit is contained in:
Jeff Bradberry 2019-04-15 15:59:40 -04:00
parent 6dae4a1d6d
commit e2861c6c39
5 changed files with 446 additions and 437 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,9 @@ import os
dir_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(dir_path, 'insights_hosts.json')) as data_file:
TEST_INSIGHTS_HOSTS = json.load(data_file)
with open(os.path.join(dir_path, 'insights.json')) as data_file:
TEST_INSIGHTS_PLANS = json.load(data_file)

View File

@ -0,0 +1,12 @@
{
"total": 1,
"count": 1,
"page": 1,
"per_page": 50,
"results": [
{
"insights_id": "11111111-1111-1111-1111-111111111111",
"updated": "2019-03-19T21:59:09.213151-04:00"
}
]
}

View File

@ -3,11 +3,12 @@
from awx.main.utils.insights import filter_insights_api_response
from awx.main.tests.data.insights import TEST_INSIGHTS_PLANS, TEST_INSIGHTS_REMEDIATIONS
from awx.main.tests.data.insights import TEST_INSIGHTS_HOSTS, TEST_INSIGHTS_PLANS, TEST_INSIGHTS_REMEDIATIONS
def test_filter_insights_api_response():
actual = filter_insights_api_response(TEST_INSIGHTS_PLANS, TEST_INSIGHTS_REMEDIATIONS)
actual = filter_insights_api_response(
TEST_INSIGHTS_HOSTS['results'][0], TEST_INSIGHTS_PLANS, TEST_INSIGHTS_REMEDIATIONS)
assert actual['last_check_in'] == '2019-03-19T21:59:09.213151-04:00'
assert len(actual['reports']) == 5

View File

@ -4,11 +4,11 @@
# Old Insights API -> New API
#
# last_check_in -> checked_on
# reports[] -> active_reports[]
# reports[].rule.{description,summary} -> active_reports[].rule.{description,summary}
# reports[].rule.category -> active_reports[].rule.category.name
# reports[].rule.severity (str) -> active_reports[].rule.total_risk (int)
# last_check_in is missing entirely, is now provided by a different endpoint
# reports[] -> []
# reports[].rule.{description,summary} -> [].rule.{description,summary}
# reports[].rule.category -> [].rule.category.name
# reports[].rule.severity (str) -> [].rule.total_risk (int)
# reports[].rule.{ansible,ansible_fix} appears to be unused
# reports[].maintenance_actions[] missing entirely, is now provided