diff --git a/puppetboard/app.py b/puppetboard/app.py index 5244afb..bfe11f4 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -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', diff --git a/test/test_app.py b/test/test_app.py index 1bd0cdf..a3cc494 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -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