From 11107fb3f6fff7a074a3f8015bee34fa93a002b2 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 13 May 2023 16:47:38 +0200 Subject: add a test for the new elevation jump transformer --- tests/assets/Elevation_Jump.gpx.gz | Bin 0 -> 4417 bytes tests/playwright/test_transformers.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/assets/Elevation_Jump.gpx.gz (limited to 'tests') diff --git a/tests/assets/Elevation_Jump.gpx.gz b/tests/assets/Elevation_Jump.gpx.gz new file mode 100644 index 0000000..836ddb1 Binary files /dev/null and b/tests/assets/Elevation_Jump.gpx.gz differ diff --git a/tests/playwright/test_transformers.py b/tests/playwright/test_transformers.py index d4f07e1..fc89afb 100644 --- a/tests/playwright/test_transformers.py +++ b/tests/playwright/test_transformers.py @@ -1,3 +1,4 @@ +import gpxpy from playwright.sync_api import Page, expect from sqlalchemy import select @@ -141,3 +142,31 @@ def test_transformer_steep_slope_edited(page: Page, playwright_helper, tmp_path, track = dbaccess.execute(select(models.Track).filter_by(id=track_id)).scalar_one() assert track.cache.uphill < 2 + + +def test_transformer_elevation_jump_enabled(page: Page, playwright_helper, tmp_path, data_manager): + playwright_helper.login() + + page.goto("/") + page.get_by_text("Upload").click() + + extract_and_upload(page, "Elevation_Jump.gpx.gz", tmp_path) + + page.locator("#transformer-heading-2 .accordion-button").click() + page.locator("#transformer-2.collapse.show").wait_for() + page.locator("#transformer-enabled-2").check() + + page.locator(".btn", has_text="Upload").click() + + page.locator(".alert", has_text="Upload successful").wait_for() + + new_track_id = int(page.url.rsplit("/", 1)[1]) + data = data_manager.open(new_track_id) + + gpx = gpxpy.parse(data.decompress_gpx()) + points = iter(gpx.walk(only_points=True)) + next(points) + for prev_point, point in zip(gpx.walk(only_points=True), points): + # The given GPX has a jump of 94 between two consecutive points, so + # here we assert that that jump is gone. + assert abs(prev_point.elevation - point.elevation) < 10.0 -- cgit v1.2.3