def test_some_data_returns_last_zero_before_data(sandbox): with sandbox.db() as db: insert(db, '1' * 40, 1111, 0) insert(db, '2' * 40, 2222, 0) insert(db, '3' * 40, 3333, 1) insert_metric_changes(db, '3' * 40, 1) assert get_first_data_timestamp('PythonImportCount', db=db) == 2222
def test_first_commit_introduces_data(sandbox): with sandbox.db() as db: insert(db, '1' * 40, 1111, 1) insert_metric_changes(db, '1' * 40, 1) insert(db, '2' * 40, 2222, 2) insert_metric_changes(db, '2' * 40, 1) assert get_first_data_timestamp('PythonImportCount', db=db) == 1111
def all_data(metric_name): earliest_timestamp = logic.get_first_data_timestamp(metric_name) now = datetime.datetime.today() return flask.redirect(flask.url_for( 'graph.show', metric_name=metric_name, start=str(earliest_timestamp), end=str(to_timestamp(now)), ))
def test_some_data_returns_first_timestamp(sandbox): with sandbox.db() as db: insert(db, '1' * 40, 1111, 0) assert get_first_data_timestamp('PythonImportCount', db=db) == 0
def test_no_data_returns_zero(sandbox): with sandbox.db() as db: assert get_first_data_timestamp('PythonImportCount', db=db) == 0