File: test_entity_filter.py

package info (click to toggle)
pyosmium 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: python: 4,400; cpp: 2,504; makefile: 20
file content (27 lines) | stat: -rw-r--r-- 825 bytes parent folder | download | duplicates (3)
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
# SPDX-License-Identifier: BSD-2-Clause
#
# This file is part of pyosmium. (https://osmcode.org/pyosmium/)
#
# Copyright (C) 2025 Sarah Hoffmann <lonvia@denofr.de> and others.
# For a full list of authors see the git log.
import pytest

import osmium
from helpers import CountingHandler


@pytest.mark.parametrize('ent,cnt', [(osmium.osm.NODE, (1, 0, 0)),
                                     (osmium.osm.NODE | osmium.osm.WAY, (1, 1, 0)),
                                     (osmium.osm.ALL, (1, 1, 1))])
def test_entity_filter_simple(opl_reader, ent, cnt):
    data = """\
           n1 Ttype=node
           w1 Ttype=way
           r1 Ttype=rel
           """

    processed = CountingHandler()

    osmium.apply(opl_reader(data), osmium.filter.EntityFilter(ent), processed)

    assert list(cnt) == processed.counts[:3]