def test_get_outliers(session, outlier_1, endpoint): outliers = get_outliers_sorted(session, endpoint_id=endpoint.id, offset=0, per_page=10) assert len(outliers) == 1 assert outliers[0].id == outlier_1.id
def result_outliers(end): rule = get_monitor_rule(end) url = get_url(end) return render_template('endpoint/outliers.html', link=config.link, session=session, rule=rule, url=url, end=end, index=7, table=get_outliers_sorted(end, Outlier.execution_time))
def test_get_outliers(self): """ Test whether the function returns the right values. """ from flask_monitoringdashboard.database.outlier import get_outliers_sorted with session_scope() as db_session: outliers = get_outliers_sorted(db_session, endpoint_id=ENDPOINT_ID, offset=0, per_page=10) self.assertEqual(len(outliers), OUTLIER_COUNT) for i, outlier in enumerate(outliers): self.assertEqual(outlier.request.endpoint.name, NAME) if i == 0: continue self.assertTrue(outlier.request.time_requested <= outliers[ i - 1].request.time_requested)
def get_outlier_table(session, endpoint_id, offset, per_page): """ :param session: session for the database :param endpoint_id: id of the endpoint :param offset: number of items to be skipped :param per_page: maximum number of items to be returned :return: a list of length at most 'per_page' with data about each outlier """ table = get_outliers_sorted(session, endpoint_id, offset, per_page) for idx, row in enumerate(table): row.request.time_requested = to_local_datetime(row.request.time_requested) try: row.request_url = row.request_url.decode('utf-8') except Exception as e: log(e) dict_request = row2dict(row.request) table[idx] = row2dict(row) table[idx]['request'] = dict_request return table
def test_get_outliers(self): """ Test whether the function returns the right values. """ from flask_monitoringdashboard.database.outlier import get_outliers_sorted, Outlier self.assertEqual(get_outliers_sorted(NAME, Outlier.time), [])