예제 #1
0
def test_attribute_during_dt_dt():
    result = parse([
        'during', ['get', 'attr'], '2000-01-01T00:00:00Z',
        '2000-01-01T00:00:01Z'
    ])

    assert result == ast.TimeDuring(
        ast.Attribute('attr'),
        values.Interval(
            datetime(2000,
                     1,
                     1,
                     0,
                     0,
                     0,
                     tzinfo=StaticTzInfo('Z', timedelta(0))),
            datetime(2000,
                     1,
                     1,
                     0,
                     0,
                     1,
                     tzinfo=StaticTzInfo('Z', timedelta(0))),
        ),
    )
예제 #2
0
def test_attribute_before_or_during_dr_dt():
    result = parse('attr BEFORE OR DURING PT4S / 2000-01-01T00:00:03Z')
    assert result == ast.TimeBeforeOrDuring(
        ast.Attribute('attr'),
        values.Interval(
            timedelta(seconds=4),
            datetime(2000,
                     1,
                     1,
                     0,
                     0,
                     3,
                     tzinfo=StaticTzInfo('Z', timedelta(0))),
        ),
    )
예제 #3
0
def test_attribute_overlappedby_dt_open():
    result = parse({
        "overlappedby": [
            {"property": "attr"},
            ["2000-01-01T00:00:03Z", ".."]
        ]
    })
    assert result == ast.TimeOverlappedBy(
        ast.Attribute('attr'),
        values.Interval(
            datetime(
                2000, 1, 1, 0, 0, 3,
                tzinfo=StaticTzInfo('Z', timedelta(0))
            ),
            None,
        ),
    )
예제 #4
0
def test_attribute_toverlaps_open_dt():
    result = parse({
        "toverlaps": [
            {"property": "attr"},
            ["..", "2000-01-01T00:00:03Z"]
        ]
    })
    assert result == ast.TimeOverlaps(
        ast.Attribute('attr'),
        values.Interval(
            None,
            datetime(
                2000, 1, 1, 0, 0, 3,
                tzinfo=StaticTzInfo('Z', timedelta(0))
            ),
        ),
    )
예제 #5
0
def test_attribute_metby_dr_dt():
    result = parse({
        "metby": [
            {"property": "attr"},
            ["PT4S", "2000-01-01T00:00:03Z"]
        ]
    })
    assert result == ast.TimeMetBy(
        ast.Attribute('attr'),
        values.Interval(
            timedelta(seconds=4),
            datetime(
                2000, 1, 1, 0, 0, 3,
                tzinfo=StaticTzInfo('Z', timedelta(0))
            ),
        ),
    )
예제 #6
0
def test_meets_dt_dr():
    result = parse({
        "meets": [
            {"property": "attr"},
            ["2000-01-01T00:00:00Z", "PT4S"]
        ]
    })
    assert result == ast.TimeMeets(
        ast.Attribute('attr'),
        values.Interval(
            datetime(
                2000, 1, 1, 0, 0, 0,
                tzinfo=StaticTzInfo('Z', timedelta(0))
            ),
            timedelta(seconds=4),
        ),
    )
예제 #7
0
def test_attribute_overlappedby_dt_open():
    result = parse(
        {
            "op": "t_overlappedby",
            "args": [
                {"property": "attr"},
                {"interval": ["2000-01-01T00:00:03Z", ".."]},
            ],
        }
    )
    assert result == ast.TimeOverlappedBy(
        ast.Attribute("attr"),
        values.Interval(
            datetime(
                2000, 1, 1, 0, 0, 3, tzinfo=StaticTzInfo("Z", timedelta(0))
            ),
            None,
        ),
    )
예제 #8
0
def test_attribute_metby_dr_dt():
    result = parse(
        {
            "op": "t_metby",
            "args": [
                {"property": "attr"},
                {"interval": ["PT4S", "2000-01-01T00:00:03Z"]},
            ],
        }
    )
    assert result == ast.TimeMetBy(
        ast.Attribute("attr"),
        values.Interval(
            timedelta(seconds=4),
            datetime(
                2000, 1, 1, 0, 0, 3, tzinfo=StaticTzInfo("Z", timedelta(0))
            ),
        ),
    )
예제 #9
0
def test_meets_dt_dr():
    result = parse(
        {
            "op": "t_meets",
            "args": [
                {"property": "attr"},
                {"interval": ["2000-01-01T00:00:00Z", "PT4S"]},
            ],
        }
    )
    assert result == ast.TimeMeets(
        ast.Attribute("attr"),
        values.Interval(
            datetime(
                2000, 1, 1, 0, 0, 0, tzinfo=StaticTzInfo("Z", timedelta(0))
            ),
            timedelta(seconds=4),
        ),
    )
예제 #10
0
def test_begins():
    # using timePosition directly
    result = parse('''
    <fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes"
        xmlns:gml="http://www.opengis.net/gml">
      <fes:Begins>
        <fes:ValueReference>attr</fes:ValueReference>
        <gml:TimePeriod>
          <gml:begin>
            <gml:TimeInstant>
              <gml:timePosition>2000-01-01T00:00:00Z</gml:timePosition>
            </gml:TimeInstant>
          </gml:begin>
          <gml:end>
            <gml:TimeInstant>
              <gml:timePosition>2001-01-01T00:00:00Z</gml:timePosition>
            </gml:TimeInstant>
          </gml:end>
        </gml:TimePeriod>
      </fes:Begins>
    </fes:Filter>
    ''')
    assert result == ast.TimeBegins(
        ast.Attribute('attr'),
        values.Interval(
            datetime(2000,
                     1,
                     1,
                     0,
                     0,
                     0,
                     tzinfo=StaticTzInfo('Z', timedelta(0))),
            datetime(2001,
                     1,
                     1,
                     0,
                     0,
                     0,
                     tzinfo=StaticTzInfo('Z', timedelta(0))),
        ),
    )
예제 #11
0
def test_attribute_after_dt_dt():
    result = parse({
        "after": [
            {"property": "attr"},
            ["2000-01-01T00:00:00Z", "2000-01-01T00:00:01Z"]
        ]
    })

    assert result == ast.TimeAfter(
        ast.Attribute('attr'),
        values.Interval(
            datetime(
                2000, 1, 1, 0, 0, 0,
                tzinfo=StaticTzInfo('Z', timedelta(0))
            ),
            datetime(
                2000, 1, 1, 0, 0, 1,
                tzinfo=StaticTzInfo('Z', timedelta(0))
            ),
        ),
    )
예제 #12
0
def test_attribute_after_dt_dt():
    result = parse(
        {
            "op": "t_after",
            "args": [
                {"property": "attr"},
                {"interval": ["2000-01-01T00:00:00Z", "2000-01-01T00:00:01Z"]},
            ],
        }
    )

    assert result == ast.TimeAfter(
        ast.Attribute("attr"),
        values.Interval(
            datetime(
                2000, 1, 1, 0, 0, 0, tzinfo=StaticTzInfo("Z", timedelta(0))
            ),
            datetime(
                2000, 1, 1, 0, 0, 1, tzinfo=StaticTzInfo("Z", timedelta(0))
            ),
        ),
    )