diff options
author | Christian Struck <christian@struck.se> | 2013-02-02 04:17:03 +0100 |
---|---|---|
committer | Christian Struck <christian@struck.se> | 2013-02-02 04:17:03 +0100 |
commit | e1981063359b0910614e5ea3f861a5ce1e54970d (patch) | |
tree | ced65c7d63233ced0892ed8800c01b7ccfe1d5c6 /tests | |
parent | 9caefee9893048f169bc451cd9c454e0af668deb (diff) | |
download | bvg-grabber-e1981063359b0910614e5ea3f861a5ce1e54970d.tar.gz bvg-grabber-e1981063359b0910614e5ea3f861a5ce1e54970d.tar.bz2 bvg-grabber-e1981063359b0910614e5ea3f861a5ce1e54970d.zip |
Added a new object to return which is easier to handle an implements a merge function if it is wished to mix actualdeparture with scheduleddeparture departures.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_api.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_api.py b/tests/test_api.py index cf111d7..113bbbf 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -3,7 +3,7 @@ import datetime import json import unittest -from bvggrabber.api import QueryApi, Departure, compute_remaining +from bvggrabber.api import QueryApi, Departure, Response, compute_remaining from bvggrabber.utils.format import fullformat @@ -42,6 +42,36 @@ class TestFunctions(unittest.TestCase): 1357092240, 1357092241) +class TestResponse(unittest.TestCase): + + def test_merge(self): + departures = [ Departure("ERP", + "HBF", + datetime.datetime(2013, 1, 2, 3, 4, 1), + "U2"), + Departure("HBF", + "ERP", + datetime.datetime(2013, 2, 1, 3, 4, 1), + "U55")] + departures2 = [ Departure("ERP", + "HBF", + datetime.datetime(2013, 1, 2, 3, 4, 1), + "U6"), + Departure("HBF", + "ERP", + datetime.datetime(2013, 2, 1, 3, 4, 1), + "U9")] + allDepartures = departures + departures2 + r1 = Response(True, departures) + r2 = Response(True, departures2) + r3 = Response(False, []) + self.assertRaises(ValueError, r1.merge, r3) + self.assertRaises(ValueError, r3.merge, r2) + self.assertRaises(TypeError, r1.merge, departures) + r1.merge(r2) + self.assertEqual(r1.departures, allDepartures) + + class TestQueryApi(unittest.TestCase): def test_call(self): |