improvements to CI test suite

This commit is contained in:
Brandon Liu
2022-07-20 16:13:14 +08:00
parent bde4a2f75c
commit be57f1f61d
8 changed files with 142 additions and 35 deletions

View File

@@ -1,10 +1,8 @@
import base64
import collections
from functools import lru_cache
import gzip
import json
import os
import re
# Exists inside all lambda functions
import boto3
@@ -12,8 +10,7 @@ from botocore.exceptions import ClientError
# create_lambda_function.py will vendor the relevant file
from pmtiles.reader import Reader
Zxy = collections.namedtuple("Zxy", ["z", "x", "y"])
from util import pmtiles_path, parse_tile_path
s3 = boto3.client("s3")
@@ -33,29 +30,6 @@ def get_object_bytes(key, offset, length):
)
def pmtiles_path(p, name):
if not p:
p = "{name}.pmtiles"
return p.replace("{name}", name)
def parse_tile_path(p, str):
if not p:
p = "/{name}/{z}/{x}/{y}.pbf"
p = re.escape(p)
p = p.replace(r"\{name\}", r"(?P<name>[0-9a-zA-Z/!\-_\.\*'\(\)]+)")
p = p.replace(r"\{z\}", r"(?P<z>\d+)")
p = p.replace(r"\{x\}", r"(?P<x>\d+)")
p = p.replace(r"\{y\}", r"(?P<y>\d+)")
m = re.match(f"^{p}$", str)
if not m:
return None, None
return (
m.group("name"),
Zxy(int(m.group("z")), int(m.group("x")), int(m.group("y"))),
)
# Assumes event is a API Gateway V2 or Lambda Function URL formatted dict
# and returns API Gateway V2 / Lambda Function dict responses
# Does not work with CloudFront events/Lambda@Edge; see README