コード例 #1
0
def test_moving_stddev_of_all_measurements(sample_data, sample_measurement,
                                           sample_database,
                                           database_with_data):
    database_client = DatabaseClient(database_with_data,
                                     db_name=sample_database)
    expected = statistics.stdev(sample_data)
    actual = database_client.moving_stddev(
        sample_measurement, time_window='{}s'.format(len(sample_data) + 1))
    assert expected == actual
コード例 #2
0
def test_moving_stddev_of_last_3_measurements(sample_data, sample_measurement,
                                              sample_database,
                                              database_with_data):
    database_client = DatabaseClient(database_with_data,
                                     db_name=sample_database)
    expected = statistics.stdev(sample_data[-3:])
    actual = database_client.moving_stddev(sample_measurement,
                                           time_window='4s')
    assert expected == actual
コード例 #3
0
def test_moving_stddev_without_measurements(sample_measurement,
                                            sample_database, database):
    database_client = DatabaseClient(database, db_name=sample_database)
    with pytest.raises(RuntimeError):
        database_client.moving_stddev(sample_measurement, time_window='0s')