1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
import logging
import pytest
from pychunked_data_view.exceptions import MarsRequestFormattingError
from z3fdb import (
AxisDefinition,
ExtractorType,
SimpleStoreBuilder,
)
logging.basicConfig(level=logging.DEBUG)
def test_additional_comma_end_of_request(
read_only_fdb_pattern_setup,
) -> None:
builder = SimpleStoreBuilder(read_only_fdb_pattern_setup)
# The individual values are scrambled to check for persistent retrieval on the FDB side
builder.add_part(
"type=an,"
"class=ea,"
"domain=g,"
"expver=0001,"
"stream=oper,"
"time=18/0/12/6,"
"date=2020-01-03/2020-01-01/2020-01-02,"
"levtype=sfc,"
"step=0,"
"param=167/165/166,", # Ending in an additional comma
[
AxisDefinition(["time"], True),
AxisDefinition(["step"], True),
AxisDefinition(["param"], True),
AxisDefinition(["date"], True),
],
ExtractorType.GRIB,
)
with pytest.raises(MarsRequestFormattingError):
builder.build()
def test_missing_comma_between_keys(
read_only_fdb_pattern_setup,
) -> None:
builder = SimpleStoreBuilder(read_only_fdb_pattern_setup)
# The individual values are scrambled to check for persistent retrieval on the FDB side
builder.add_part(
"type=an,"
"class=ea,"
"domain=g,"
"expver=0001,"
"stream=oper,"
"time=18/0/12/6" # Missing comma here
"date=2020-01-03/2020-01-01/2020-01-02,"
"levtype=sfc,"
"step=0,"
"param=167/165/166",
[
AxisDefinition(["time"], True),
AxisDefinition(["step"], True),
AxisDefinition(["param"], True),
AxisDefinition(["date"], True),
],
ExtractorType.GRIB,
)
with pytest.raises(MarsRequestFormattingError):
builder.build()
def test_wrong_key(
read_only_fdb_pattern_setup,
) -> None:
builder = SimpleStoreBuilder(read_only_fdb_pattern_setup)
# The individual values are scrambled to check for persistent retrieval on the FDB side
builder.add_part(
"type=an,"
"class=ea,"
"domain=g,"
"blubb=0001," # There is no blubb key
"stream=oper,"
"time=18/0/12/6,"
"date=2020-01-03/2020-01-01/2020-01-02,"
"levtype=sfc,"
"step=0,"
"param=167/165/166",
[
AxisDefinition(["time"], True),
AxisDefinition(["step"], True),
AxisDefinition(["param"], True),
AxisDefinition(["date"], True),
],
ExtractorType.GRIB,
)
with pytest.raises(MarsRequestFormattingError):
builder.build()
|