tests package

Submodules

tests.test_config module

Unit test for Config.py

class tests.test_config.TestConfig(methodName='runTest')

Bases: unittest.case.TestCase

A TestCase class for testing the Config class.

setUp():

Initializes the Config object for each test method.

test_starting_home_location():

Tests the starting home location functionality by plotting the location start, location end, and polygon borders and obstacles using the Config class methods.

test_wgs_starting_home_location():

Tests the WGS starting home location functionality by plotting the location start, location end, and polygon borders and obstacles using the Config class methods.

setUp() None

Initializes the Config object for each test method.

test_starting_home_location()

Tests the starting home location functionality by plotting the location start, location end, and polygon borders and obstacles using the Config class methods.

test_wgs_starting_home_location()

Tests the WGS starting home location functionality by plotting the location start, location end, and polygon borders and obstacles using the Config class methods.

tests.test_field module

This module tests the field object.

class tests.test_field.TestField(methodName='runTest')

Bases: unittest.case.TestCase

A TestCase class for testing the Field class.

setUp() None

Initializes the Field object for each test method.

test_border_contains() None

Test if border contains a point.

Raises

AssertionError – If the point is not within the border polygon.

Examples

>>> self.f.border_contains([1e6, 1e6])
False
>>> self.f.border_contains([0, 0])
True
Returns

None

test_border_in_the_way() None

Test if border is in the way of a line.

Raises

AssertionError – If the line is not colliding with the border.

Examples

>>> self.f.is_border_in_the_way([0, 0], [5000, 0])
True
>>> self.f.is_border_in_the_way([0, 0], [5000, 10])
True
>>> self.f.is_border_in_the_way([0, 0], [1000, 1000])
False
Returns

None

test_empty_grids() None

Test if it generates empty waypoint.

Raises

AssertionError – If the waypoint is empty.

test_get_ind_from_locations() None

Test waypoint interpolation works. Given random location, it should return indices for the nearest locations.

Raises

AssertionError – If the waypoint is not correct.

Examples

>>> self.f.get_ind_from_location([0.5, 0.5])
10
>>> self.f.get_ind_from_location([[0.5, 1.5], [1.5, 1.5], [2.5, 1.5]])
[11, 13, 15]
Returns

None

test_get_locations_from_ind() None

Test if it returns the correct waypoint given the index.

Raises

AssertionError – If the waypoint is not correct.

Examples

>>> self.f.get_location_from_ind(10)
np.array([ 0.5,  0.5])
>>> self.f.get_location_from_ind([11, 13, 15])
np.array([[ 0.5,  1.5], [ 1.5,  1.5], [ 2.5,  1.5]])
Returns

None

test_get_neighbours() None

Test if neighbours are within a certain distance.

Raises

AssertionError – If the distance is not within the threshold.

Examples

>>> self.f.get_neighbours(0)
[1, 2, 3, 4, 5, 6, 7, 8]
>>> self.f.get_neighbours(222)
[221, 223, 224, 225, 226, 227]  # filtered to avoid collisions.
Returns

None

test_illegal_grids() None

Test if any waypoints are not within the border polygon or colliding with obstacles.

Raises

AssertionError – If the waypoint is not within the border polygon or colliding with obstacles.

tests.test_grf module

Module contents