Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def mock_puppetdb_environments(mocker):
environemnts = [
{'name': 'production'},
{'name': 'staging'}
]
return mocker.patch.object(app.puppetdb, 'environments',
return_value=environemnts)
def test_db_version_good(mocker, mock_info_log):
mocker.patch.object(app.puppetdb, 'current_version', return_value='4.2.0')
err = 'PuppetDB Version %d.%d.%d' % (4, 2, 0)
result = utils.get_db_version(app.puppetdb)
mock_info_log.assert_called_with(err)
assert (4, 0, 0) < result
assert (4, 2, 0) == result
assert (3, 2, 0) < result
assert (4, 3, 0) > result
assert (5, 0, 0) > result
assert (4, 2, 1) > result
def mock_puppetdb_environments(mocker):
environemnts = [
{'name': 'production'},
{'name': 'staging'}
]
return mocker.patch.object(app.puppetdb, 'environments',
return_value=environemnts)
def test_db_empty_response(mocker, mock_err_log):
err = "Empty Response"
def connection_error():
raise EmptyResponseError(err)
mocker.patch.object(app.puppetdb, 'current_version',
side_effect=connection_error)
result = utils.get_db_version(app.puppetdb)
mock_err_log.assert_called_with(err)
assert result == ()
}
},
{
'validate': {
'data': {'Value': 60.3},
'checks': {
'path': '%sname=avg-resources-per-node' % base_str
}
}
}
]
}
dbquery = MockDbQuery(query_data)
mocker.patch.object(app.puppetdb, '_query', side_effect=dbquery.get)
rv = client.get('/%2A/radiator')
assert rv.status_code == 200
soup = BeautifulSoup(rv.data, 'html.parser')
assert soup.title.contents[0] == 'Puppetboard'
assert soup.h1 != 'Not Found'
total = soup.find(class_='total')
assert '50' in total.text