Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub action to run unit tests #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/.tests-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit tests

on:
push:
pull_request:

jobs:
tests:
name: python ${{ matrix.python-version }}
runs-on: ubuntu-latest
container: python:${{ matrix.python-version }}
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Upgrade pip
run: python3 -m pip install --upgrade pip
- name: Create and source virtual environment
run: |
python3 -m venv .venv
. .venv/bin/activate
- name: Install requirements
run: python3 -m pip install -r requirements.txt
- name: Run unit tests
run: python -m unittest
10 changes: 5 additions & 5 deletions staticmap/tests.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from unittest import TestCase

from staticmap import StaticMap
from staticmap.staticmap import _lat_to_y, _lon_to_x, _y_to_lat, _x_to_lon


class LonLatConversionTest(TestCase):
def testLon(self):
for lon in range(-180, 180, 20):
for zoom in range(0, 10):
x = _lon_to_x(zoom)
l = _x_to_lon(zoom)
x = _lon_to_x(lon, zoom)
l = _x_to_lon(x, zoom)
self.assertAlmostEqual(lon, l, places=5)

def testLat(self):
for lat in range(-89, 89, 2):
for zoom in range(0, 10):
y = _lat_to_y(zoom)
l = _y_to_lat(zoom)
y = _lat_to_y(lat, zoom)
l = _y_to_lat(y, zoom)
self.assertAlmostEqual(lat, l, places=5)