Catalogs tests - better data testing
This commit is contained in:
@@ -857,7 +857,9 @@ def catalogs(env, compare):
|
||||
return render_template(
|
||||
'catalogs.html',
|
||||
compare=compare,
|
||||
columns=CATALOGS_COLUMNS)
|
||||
columns=CATALOGS_COLUMNS,
|
||||
envs=envs,
|
||||
current_env=env)
|
||||
|
||||
|
||||
@app.route('/catalogs/json',
|
||||
|
||||
@@ -71,13 +71,6 @@ def mock_puppetdb_default_nodes(mocker):
|
||||
catalog_timestamp='2013-08-01T09:57:00.000Z',
|
||||
facts_timestamp='2013-08-01T09:57:00.000Z',
|
||||
status_report='unchanged'),
|
||||
Node('_', 'node-skipped',
|
||||
report_timestamp='2013-08-01T09:57:00.000Z',
|
||||
latest_report_hash='1234567',
|
||||
catalog_timestamp='2013-08-01T09:57:00.000Z',
|
||||
facts_timestamp='2013-08-01T09:57:00.000Z',
|
||||
status_report='skipped')
|
||||
|
||||
]
|
||||
return mocker.patch.object(app.puppetdb, 'nodes',
|
||||
return_value=iter(node_list))
|
||||
@@ -443,7 +436,6 @@ def test_radiator_view_json(client, mocker,
|
||||
assert json_data['noop'] == 1
|
||||
assert json_data['failed'] == 1
|
||||
assert json_data['changed'] == 1
|
||||
assert json_data['skipped'] == 1
|
||||
assert json_data['unchanged'] == 1
|
||||
|
||||
|
||||
@@ -587,13 +579,26 @@ def test_catalogs_json(client, mocker,
|
||||
|
||||
for line in result_json['data']:
|
||||
assert len(line) == 3
|
||||
found_status = None
|
||||
for status in ['failed', 'changed', 'unchanged', 'noop', 'unreported']:
|
||||
val = BeautifulSoup(line[0], 'html.parser').find_all(
|
||||
'a', {"href": "/node/node-%s/" % status})
|
||||
if len(val) == 1:
|
||||
found_status = status
|
||||
break
|
||||
assert found_status, 'Line does not match any known status'
|
||||
|
||||
val = BeautifulSoup(line[2], 'html.parser').find_all(
|
||||
'form', {"method": "GET",
|
||||
"action": "/catalogs/compare/node-%s" % found_status})
|
||||
assert len(val) == 1
|
||||
|
||||
|
||||
def test_catalogs_json_compare(client, mocker,
|
||||
mock_puppetdb_environments,
|
||||
mock_puppetdb_default_nodes):
|
||||
app.app.config['ENABLE_CATALOG'] = True
|
||||
rv = client.get('/catalogs/compare/1234567/json')
|
||||
rv = client.get('/catalogs/compare/node-unreported/json')
|
||||
assert rv.status_code == 200
|
||||
|
||||
result_json = json.loads(rv.data.decode('utf-8'))
|
||||
@@ -601,3 +606,17 @@ def test_catalogs_json_compare(client, mocker,
|
||||
|
||||
for line in result_json['data']:
|
||||
assert len(line) == 3
|
||||
found_status = None
|
||||
for status in ['failed', 'changed', 'unchanged', 'noop', 'unreported']:
|
||||
val = BeautifulSoup(line[0], 'html.parser').find_all(
|
||||
'a', {"href": "/node/node-%s/" % status})
|
||||
if len(val) == 1:
|
||||
found_status = status
|
||||
break
|
||||
assert found_status, 'Line does not match any known status'
|
||||
|
||||
val = BeautifulSoup(line[2], 'html.parser').find_all(
|
||||
'form', {"method": "GET",
|
||||
"action": "/catalogs/compare/node-unreported...node-%s" %
|
||||
found_status})
|
||||
assert len(val) == 1
|
||||
|
||||
Reference in New Issue
Block a user