Skip to content

Commit ad59dd0

Browse files
committed
add test for regression around deletion in extracts
See osmcode/libosmium#403.
1 parent 4746d9d commit ad59dd0

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

test/test_pyosmium_up-to-date.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ def _state(seq):
4141
return httpserver.url_for('')
4242

4343

44+
@pytest.fixture
45+
def replication_server_delete(httpserver):
46+
def _state(seq):
47+
seqtime = REPLICATION_BASE_TIME + dt.timedelta(hours=seq - REPLICATION_CURRENT)
48+
timestamp = seqtime.strftime('%Y-%m-%dT%H\\:%M\\:%SZ')
49+
return f"sequenceNumber={seq}\ntimestamp={timestamp}\n"
50+
51+
httpserver.no_handler_status_code = 404
52+
httpserver.expect_request('/state.txt').respond_with_data(_state(REPLICATION_CURRENT))
53+
for i in range(REPLICATION_BASE_SEQ, REPLICATION_CURRENT + 1):
54+
httpserver.expect_request(f'/000/000/{i}.opl')\
55+
.respond_with_data(f"n{i} v2 dD")
56+
httpserver.expect_request(f'/000/000/{i}.state.txt').respond_with_data(_state(i))
57+
58+
return httpserver.url_for('')
59+
60+
4461
@pytest.fixture
4562
def runner(replication_server):
4663
def _run(*args):
@@ -79,6 +96,18 @@ def test_simple_update_override(runner, test_data):
7996
assert ids.relations == list(range(138, REPLICATION_CURRENT + 1))
8097

8198

99+
def test_simple_update_delete(replication_server_delete, test_data):
100+
outfile = test_data("n138 v1 t2070-05-06T19:30:00Z x3 y5\nn139 v2 x3 y5\nn140 v3 x3 y5")
101+
102+
pyosmium_up_to_date(
103+
['--server', replication_server_delete, '--diff-type', 'opl', str(outfile)])
104+
105+
ids = IDCollector()
106+
osmium.apply(outfile, ids)
107+
108+
assert ids.nodes == [140]
109+
110+
82111
def test_simple_update_new_file(runner, replication_server, test_data, tmp_path):
83112
outfile = test_data("n1 v1 t2070-05-06T19:30:00Z")
84113
newfile = tmp_path / f"{uuid.uuid4()}.pbf"

0 commit comments

Comments
 (0)