diff options
author | Daniel Schadt <kingdread@gmx.de> | 2023-05-13 16:47:38 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2023-05-13 16:47:38 +0200 |
commit | 11107fb3f6fff7a074a3f8015bee34fa93a002b2 (patch) | |
tree | ca9e3dad3bd8cd914049c6c7b469bfcc332d3f0b /tests | |
parent | 533a96345eef12eb8fe0a41666703a60e62ff06f (diff) | |
download | fietsboek-11107fb3f6fff7a074a3f8015bee34fa93a002b2.tar.gz fietsboek-11107fb3f6fff7a074a3f8015bee34fa93a002b2.tar.bz2 fietsboek-11107fb3f6fff7a074a3f8015bee34fa93a002b2.zip |
add a test for the new elevation jump transformer
Diffstat (limited to 'tests')
-rw-r--r-- | tests/assets/Elevation_Jump.gpx.gz | bin | 0 -> 4417 bytes | |||
-rw-r--r-- | tests/playwright/test_transformers.py | 29 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/assets/Elevation_Jump.gpx.gz b/tests/assets/Elevation_Jump.gpx.gz Binary files differnew file mode 100644 index 0000000..836ddb1 --- /dev/null +++ b/tests/assets/Elevation_Jump.gpx.gz 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 |