-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38ca02d
commit d9aea97
Showing
2 changed files
with
58 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,61 @@ | ||
"""Unit test for the elcpy module. | ||
""" | ||
import sys, unittest, wsdotelc | ||
"""Unit test for the elcpy module.""" | ||
|
||
import unittest | ||
import wsdotelc | ||
|
||
|
||
class Test_unittest(unittest.TestCase): | ||
def setUp(self): | ||
self.elc = wsdotelc.Elc() | ||
|
||
def test_routes(self): | ||
"""Test the retrieval of `elcpy.Elc.routes`. | ||
""" | ||
"""Test the retrieval of `elcpy.Elc.routes`.""" | ||
routes = self.elc.routes | ||
self.assertTrue(isinstance(routes, dict), "Returned routes object is a dict.") | ||
self.assertTrue(isinstance(self.elc._routes, dict), "Route dict has been cached.") | ||
self.assertTrue( | ||
isinstance(self.elc._routes, dict), "Route dict has been cached." | ||
) | ||
|
||
def test_find_route_locations(self): | ||
"""Test the `elcpy.Elc.find_route_locations` function. | ||
""" | ||
#locations = (elcpy.RouteLocation(route="005", arm=5, reference_date="12/31/2013")) | ||
"""Test the `elcpy.Elc.find_route_locations` function.""" | ||
# locations = (elcpy.RouteLocation(route="005", arm=5, reference_date="12/31/2013")) | ||
# Create a set of locations. | ||
locations = (wsdotelc.RouteLocation(Route="005", Arm=5),) | ||
out_locations = self.elc.find_route_locations(locations, "12/31/2013") | ||
self.assertEqual(len(out_locations), 1, "Result has single element.") | ||
self.assertIsInstance(out_locations[0], wsdotelc.RouteLocation, "The first element in the returned array is an `elcpy.RouteLocation`.") | ||
self.assertIsInstance( | ||
out_locations[0], | ||
wsdotelc.RouteLocation, | ||
"The first element in the returned array is an `elcpy.RouteLocation`.", | ||
) | ||
|
||
def test_find_nearest_route_location(self): | ||
"""Test the `elcpy.Elc.find_dearest_route_locations` function. | ||
""" | ||
"""Test the `elcpy.Elc.find_dearest_route_locations` function.""" | ||
points = [1087403.28714286, 136623.00728571415] | ||
out_locations = self.elc.find_nearest_route_locations(points, "12/31/2013", 200, 2927) | ||
self.assertEqual(1, len(out_locations), "Input and output loctions should have the same number of elements.") | ||
self.assertIsInstance(out_locations[0], wsdotelc.RouteLocation, "The first element in the returned array is an `elcpy.RouteLocation`.") | ||
self.assertListEqual([out_locations[0].Route, out_locations[0].Arm], ["005", 5], "Test for expected Route ID and ARM values.") | ||
out_locations = self.elc.find_nearest_route_locations( | ||
points, "12/31/2013", 200, 2927 | ||
) | ||
self.assertEqual( | ||
1, | ||
len(out_locations), | ||
"Input and output loctions should have the same number of elements.", | ||
) | ||
self.assertIsInstance( | ||
out_locations[0], | ||
wsdotelc.RouteLocation, | ||
"The first element in the returned array is an `elcpy.RouteLocation`.", | ||
) | ||
self.assertListEqual( | ||
[out_locations[0].Route, out_locations[0].Arm], | ||
["005", 5], | ||
"Test for expected Route ID and ARM values.", | ||
) | ||
|
||
#def test_A(self): | ||
# def test_A(self): | ||
# self.fail("Not implemented") | ||
|
||
if __name__ == '__main__': | ||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
# suite = unittest.TestLoader().loadTestsFromTestCase(Test_unittest) | ||
# unittest.TextTestRunner(verbosity=2).run(suite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters