Skip to content

Commit

Permalink
#3 Tests:
Browse files Browse the repository at this point in the history
-Set up ci
-First test
  • Loading branch information
FABallemand committed Jun 14, 2023
1 parent bd6e865 commit 490cbb5
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci
on: [push]

jobs:
activate:
runs-on: self-ubuntu-22.04
if: |
github.repository == 'FABallemand/ezGPX' &&
!startsWith(github.event.head_commit.message, 'Release ') &&
!contains(github.event.head_commit.message, 'ci skip')
steps:
- run: echo ready

tests:
needs: activate
runs-on: self-ubuntu-22.04
steps:
- name: install and upgrade necessary packages
run: |
python3 -m pip install --upgrade pip
pip3 install pytest pandas
- name: tests
run: |
python3 -c"import sys; print(sys.path)"
python3 -m pytest -s
2 changes: 1 addition & 1 deletion ezgpx/gpx_elements/track.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from track_extensions import *
from .track_extensions import *
from .track_segment import *

class Track():
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions tests/test_GPX.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sys
import os
import pytest
from shutil import rmtree

import numpy as np
import matplotlib.pyplot as plt

file_folder = os.path.dirname(__file__)
parent_folder = os.path.realpath(os.path.dirname(file_folder)) # ie: ezGPX

os.chdir(file_folder)
sys.path.append(parent_folder + "/ezgpx")

from ezgpx import GPX

class TestGPX():

def test_plot(self, remove_tmp: bool = True):
# Create temporary folder
rmtree("tmp", True)
os.makedirs(os.path.dirname(__file__) + "/tmp")

# Plot
test_gpx = GPX("../test_files/files/strava_running_1.gpx")
test_gpx.plot(start_stop=True, elevation_color=True, file_path="tmp/strava_running_1_start_stop_elevation.png")

# Load images
test_img = plt.imread("tmp/strava_running_1_start_stop_elevation.png")
ref_img = plt.imread("../test_files/reference_files/strava_running_1_start_stop_elevation.png")

res = np.array_equal(test_img, ref_img)

# Create temporary folder
if remove_tmp:
rmtree("tmp")

assert(res)

@pytest.mark.skip(reason="test") # https://docs.pytest.org/en/7.3.x/how-to/skipping.html
def test_test(self):
print("Testing...")

0 comments on commit 490cbb5

Please sign in to comment.