[Tile-serving] [osm2pgsql-dev/osm2pgsql] Add script for style testing (PR #2436)

Jochen Topf notifications at github.com
Wed Dec 3 10:02:44 UTC 2025


@joto requested changes on this pull request.



>  ```
 
-Per default, behave assumes that the build directory is under `osm2pgsql/build`.
-If your setup works like that, you can leave out the `-D` parameter.
-
 To make this a bit easier a shell script `run-behave` is provided in your

If I understand this correctly, `run-behave` is not installed any more, but still mentioned here.

> +
+def opl_sort(line):
+    oid = line.split(' ', 1)[0]
+    return OBJECT_ORDER[oid[0]], int(oid[1:])
+
+#################### Replication mock ##############################
+
+class ReplicationServerMock:
+
+    def __init__(self, base_url, state_infos):
+        self.expected_base_url = base_url
+        self.state_infos = state_infos
+
+    def __call__(self, base_url):
+        assert base_url == self.expected_base_url,\
+               f"Wrong replication service called. Expected '{self.expected_base_url}', got '{base_url}'"

Line continuation formatting with backslash is inconsistent in whole file: sometimes with, somtimes without space in front.

Also: There are some line continuations after a comma which should not be needed?

> +def setup_style_inline(context):
+    outfile = context.workdir / 'inline_style.lua'
+    outfile.write_text(context.text)
+
+    context.osm2pgsql_params['-S'] = str(outfile)
+
+
+################### Steps: Running osm2pgsql #######################
+
+ at when(r"running osm2pgsql(?P<output> \w+)?(?: with parameters)?")
+def execute_osm2pgsql(context, output):
+    assert output in (' flex', ' pgsql', ' null', None)
+
+    if output is not None:
+        context.osm2pgsql_params['-O'] = output.strip()
+    if output == ' pgsql' and 'S' not in context.osm2pgsql_params:

Shouldn't this bis `'-S' not in`?

> +        context.import_data = None
+        cmdline.extend(('-r', 'opl', '-'))
+    else:
+        assert context.import_file is not None, "No input data given."
+        cmdline.append(str(context.import_file))
+        context.import_file = None
+        data_stdin = None
+
+    proc = Popen(cmdline, cwd=str(context.workdir),
+                 stdin=PIPE, stdout=PIPE, stderr=PIPE)
+
+    outdata = proc.communicate(input=data_stdin)
+    context.osm2pgsql_cmdline = ' '.join(cmdline)
+    context.osm2pgsql_outdata = [d.decode('utf-8').replace('\\n', '\n') for d in outdata]
+    context.osm2pgsql_returncode = proc.returncode
+    context.osm2pgsql_params = {'-d': context.user_args.test_db}

Why is this set here *after* building the command line in line 503 and 507?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2436#pullrequestreview-3533771909
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/pull/2436/review/3533771909 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20251203/61e07c24/attachment-0001.htm>


More information about the Tile-serving mailing list