Example #1
0
def test_interpolation_type_mapping(client: Client, suffix_source):
    many_series = list(client.search(SeriesSelector(
        suffix_source("sql-list"))))
    interpolation_types = [(metadata.series.name, metadata.interpolation_type)
                           for metadata in many_series]
    assert ("test-tag-1", InterpolationType.LINEAR) in interpolation_types
    assert ("test-tag-4", InterpolationType.STEPPED) in interpolation_types
Example #2
0
def test_metadata_no_dictionary_query(client: Client, suffix_source):
    dictionary_series = client.get_metadata(
        SeriesSelector(suffix_source("sql-no-dictionary-query"), "test-tag-6"))
    assert dictionary_series.description == "A dictionary series"
    assert dictionary_series.interpolation_type == InterpolationType.STEPPED
    assert dictionary_series.dictionary_name == "Active"
    assert dictionary_series.dictionary is None
Example #3
0
def test_metadata(client: Client):
    dictionary_series = client.get_metadata(SeriesSelector("row", "test-tag-6"))
    assert dictionary_series.description == "Valve X"
    assert dictionary_series.dictionary_name == "Active"
    assert dictionary_series.dictionary is not None
    assert len(dictionary_series.dictionary.mapping) == 2
    assert dictionary_series.dictionary.mapping[0] == "OFF"
    assert dictionary_series.dictionary.mapping[1] == "ON"
Example #4
0
def test_search(client: Client):
    many_series = list(client.search(SeriesSelector(suffix_source("noaa"))))
    assert len(many_series) == 16
    series = [
        series for series in many_series
        if series.series.name == "h2o_feet,location=coyote_creek::water_level"
    ][0]
    assert series.limit_low == 6
    assert series.limit_high == 9
Example #5
0
def test_data(client: Client):
    start_date = datetime.fromisoformat("2020-01-01T00:00:00+00:00")
    end_date = datetime.fromisoformat("2021-01-01T00:00:00+00:00")
    data = client.get_data(SeriesSelector("row", "test-tag-6"), start_date, end_date)
    assert len(data) == 7
    assert data["ts"][0].as_py() == start_date
    assert data["value"][0].as_py() == 1.0
    assert data["ts"][6].as_py() == datetime.fromisoformat("2020-07-01T00:00:00+00:00")
    assert data["value"][6].as_py() == 1.0
Example #6
0
def test_metadata_string_query(client: Client, suffix_source):
    dictionary_series = client.get_metadata(
        SeriesSelector(suffix_source("sql-string"), "test-tag-6"))
    assert dictionary_series.description == "A dictionary series"
    assert dictionary_series.interpolation_type == InterpolationType.STEPPED
    assert dictionary_series.dictionary_name == "Active"
    assert dictionary_series.dictionary is not None
    assert len(dictionary_series.dictionary.mapping) == 2
    assert dictionary_series.dictionary.mapping[0] == "OFF"
    assert dictionary_series.dictionary.mapping[1] == "ON"
Example #7
0
def test_search(client: Client):
    many_series = list(client.search(SeriesSelector("row")))
    assert len(many_series) == 5
    dictionary_series = [
        series for series in many_series if series.series.name == "test-tag-6"
    ][0]
    assert dictionary_series.description == "Valve X"
    assert dictionary_series.dictionary_name == "Active"
    assert dictionary_series.dictionary is not None
    assert len(dictionary_series.dictionary.mapping) == 2
    assert dictionary_series.dictionary.mapping[0] == "OFF"
    assert dictionary_series.dictionary.mapping[1] == "ON"
Example #8
0
def test_data_string_query(client: Client, suffix_source):
    start_date = datetime.fromisoformat("2020-01-01T00:00:00+00:00")
    end_date = datetime.fromisoformat("2021-01-01T00:00:00+00:00")
    data = client.get_data(
        SeriesSelector(suffix_source("sql-string"), "test-tag-6"), start_date,
        end_date)
    assert len(data) == 5
    assert data["ts"][0].as_py() == start_date
    assert data["value"][0].as_py() == 1.0
    assert data["ts"][4].as_py() == datetime.fromisoformat(
        "2020-05-01T00:00:00+00:00")
    assert data["value"][4].as_py() == 1.0
Example #9
0
def test_data(client: Client):
    start_date = datetime.fromisoformat("2019-09-17T00:00:00+00:00")
    end_date = datetime.fromisoformat("2019-09-17T16:24:00+00:00")
    data = client.get_data(
        SeriesSelector(suffix_source("noaa"),
                       "h2o_feet,location=coyote_creek::water_level"),
        start_date,
        end_date,
    )
    assert len(data) == 165
    assert data["ts"][0].as_py() == start_date
    assert data["value"][0].as_py() == 8.412
    assert data["ts"][164].as_py() == end_date
    assert data["value"][164].as_py() == 3.235
Example #10
0
def test_search(client: Client, suffix_source):
    many_series = list(client.search(SeriesSelector(
        suffix_source("sql-list"))))
    assert len(many_series) == 4
    dictionary_series = [
        series for series in many_series if series.series.name == "test-tag-6"
    ][0]
    assert dictionary_series.description == "A dictionary series"
    assert dictionary_series.interpolation_type == InterpolationType.STEPPED
    assert dictionary_series.dictionary_name == "Active"
    assert dictionary_series.dictionary is not None
    assert len(dictionary_series.dictionary.mapping) == 2
    assert dictionary_series.dictionary.mapping[0] == "OFF"
    assert dictionary_series.dictionary.mapping[1] == "ON"
Example #11
0
def test_metadata(client: Client):
    series = client.get_metadata(
        SeriesSelector(suffix_source("noaa"),
                       "h2o_feet,location=coyote_creek::water_level"))
    assert series.limit_low == 6
    assert series.limit_high == 9
Example #12
0
def client() -> Client:
    kukur_client = Client()
    kukur_client._get_client().wait_for_available(timeout=10)
    return kukur_client
Example #13
0
def test_sources(client: Client):
    data = client.list_sources()
    assert len(data) == 25
    assert "sql" in data
    assert "row" in data
    assert "noaa" in data