Skip to content

Commit

Permalink
tests upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
firefly-cpp committed Mar 15, 2021
1 parent 907f386 commit 1c5588f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 37 deletions.
Empty file added tcxreader/tests/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions tcxreader/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import logging

def pytest_configure(config):
r"""Disable verbose output when running tests."""
logging.basicConfig(level=logging.DEBUG)
File renamed without changes.
39 changes: 39 additions & 0 deletions tcxreader/tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
from unittest import TestCase
from tcxreader.tcxreader import TCXReader, TCXTrackPoint, TCXExercise


class TestTCXReader(TestCase):
def setUp(self):
filename = os.path.join(os.path.dirname(__file__), "data", '15.tcx')
self.tcx = TCXReader().read(filename)

def test_distance(self):
self.assertEqual(self.tcx.distance, 116366.98)

def test_duration(self):
self.assertEqual(self.tcx.duration, 17250.0)

def test_calories(self):
self.assertEqual(self.tcx.calories, 2010)

def test_hr_avg(self):
self.assertEqual(int(self.tcx.hr_avg), 140)

def test_hr_max(self):
self.assertEqual(self.tcx.hr_max, None)

def test_hr_min(self):
self.assertEqual(self.tcx.hr_min, 94)

def altitude_avg(self):
self.assertEqual(self.tcx.altitude_avg, None)

def test_altitude_min(self):
self.assertAlmostEqual(self.tcx.altitude_min, -5.4, places=1)

def test_ascent(self):
self.assertAlmostEqual(self.tcx.ascent, 1404.4, places=1)

def test_descent(self):
self.assertAlmostEqual(self.tcx.descent, 1422.0, places=1)
Empty file added tests/__init__.py
Empty file.
39 changes: 2 additions & 37 deletions tests/test_tcxreader.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
import os
from unittest import TestCase
from tcxreader.tcxreader import TCXReader, TCXTrackPoint, TCXExercise
from tcxreader.tests.conftest import pytest_configure

__all__ = ["pytest_configure"]

class TestTCXReader(TestCase):
def setUp(self):
filename = os.path.join(os.path.dirname(__file__), "data", '15.tcx')
self.tcx = TCXReader().read(filename)

def test_distance(self):
self.assertEqual(self.tcx.distance, 116366.98)

def test_duration(self):
self.assertEqual(self.tcx.duration, 17250.0)

def test_calories(self):
self.assertEqual(self.tcx.calories, 2010)

def test_hr_avg(self):
self.assertEqual(int(self.tcx.hr_avg), 140)

def test_hr_max(self):
self.assertEqual(self.tcx.hr_max, None)

def test_hr_min(self):
self.assertEqual(self.tcx.hr_min, 94)

def altitude_avg(self):
self.assertEqual(self.tcx.altitude_avg, None)

def test_altitude_min(self):
self.assertAlmostEqual(self.tcx.altitude_min, -5.4, places=1)

def test_ascent(self):
self.assertAlmostEqual(self.tcx.ascent, 1404.4, places=1)

def test_descent(self):
self.assertAlmostEqual(self.tcx.descent, 1422.0, places=1)

0 comments on commit 1c5588f

Please sign in to comment.