gpxity.backends.test package

define things that should be visible to the user.

gpxity.backends.test.basic module

Tests for gpxity.backends.

class gpxity.backends.test.basic.BasicTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

define some helpers.

assertEqualTracks(track1, track2, msg=None, xml: bool = False, with_category: bool = True)[source]

both tracks must be identical. We test more than necessary for better test coverage.

Parameters:xml – if True, also compare to_xml()
assertNotEqualTracks(track1, track2, msg=None, with_category: bool = True)[source]

both tracks must be different. We test more than necessary for better test coverage.

assertSameTracks(backend1, backend2, msg=None, with_category=True, with_last_time=None)[source]

both backends must hold identical tracks.

assertTrackFileContains(track, string, msg=None)[source]

Assert that string is in the physical file. Works only for Directory backend.

classmethod create_db_for_wptrackserver()[source]

Create the mysql database for the WPTrackserver tests.

classmethod create_temp_mysqld()[source]

Create a temporary mysql server and initialize it with test data for WPTrackserver.

classmethod create_test_track(count: int = 1, idx: int = 0, category: str = None, public: bool = False, start_time=None, end_time=None)[source]

create a Track.

It starts off with test.gpx and appends a last track point, it also changes the time stamp of the last point. This is done using count and idx: The last point is set such that looking at the tracks, they all go in a different direction clockwise, with an angle in degrees of 360 * idx / count.

Parameters:
  • count – See above. Using 1 as default if not given.
  • idx – See above. Using 0 as default if not given.
  • category – The wanted value for the track. Default: if count == len(Track.categories), the default value will be categories[idx]. Otherwise a random value will be applied.
  • public – should the tracks be public or private?
  • start_time – If given, assign it to the first point and adjust all following times
  • end_time – explicit time for the last point. If None: See above.
Returns:

A new track not bound to a backend

Return type:

(Track)

classmethod find_mysql_docker() → bool[source]

Find an already running docker.

Returns:the IP address
static lifetrackserver(directory)[source]

Start and ends a server for lifetrack testing.

mysql_docker_name = 'gpxitytest_mysql'
mysql_ip_address = None
setUp()[source]

define test specific Directory.prefix.

setup_backend(cls_, username: str = None, url: str = None, count: int = 0, cleanup: bool = None, clear_first: bool = None, category: str = None, public: bool = None)[source]

set up an instance of a backend with count tracks.

If count == len(Track.categories), the list of tracks will always be identical. For an example see TestBackends.test_all_category.

Parameters:
  • cls (Backend) – the class of the backend to be created
  • username – use this to for a specific accout name. Default is ‘gpxitytest’. Special case WPTrackserver: pass the IP address of the mysql test server
  • url – for the backend
  • count – how many random tracks should be inserted?
  • cleanup – If True, remove all tracks when done. Passed to the backend. None: do if the backend supports it.
  • clear_first – if True, first remove all existing tracks. None: do if the backend supports it.
  • category – The wanted category, one out of Track.categories. But this is a problem because we do the same call for all backend classes and they support different categories. So: If category is int, this is an index into Backend.supported_categories which will be decoded into Track.categories
  • public – should the tracks be public or private? If None, use Backend default.
Returns:

the prepared Backend

start_mailserver()[source]

Start an smptd server for mail testing.

stop_mailserver()[source]

Stop the smtp server for mail testing.

tearDown()[source]

Check if there are still /tmp/gpxitytest.* directories.

temp_backend(cls_, url=None, count=0, cleanup=None, clear_first=None, category=None, public: bool = None, username=None)[source]

Just like setup_backend but usable as a context manager. which will call destroy() when done.

test_passwd = 'pwd'
tst_backend(backend_cls)[source]

With pytest, subTest does not do much. At least print the name.

gpxity.backends.test.test_track module

implements test classes for Track.

They only use backend Directory, so there is no network traffic involved (unless Directory is a network file system, of course).

class gpxity.backends.test.test_track.TrackTests(methodName='runTest')[source]

Bases: gpxity.backends.test.basic.BasicTest

track tests.

test_add_points()[source]

test Track.add_points.

test_adjust_time()[source]

adjust_time().

test_all_backend_classes()[source]

Test Backend.all_backend_classes.

test_angle()[source]

test Track.angle.

test_clone()[source]

True if the clone is identical.

test_combine()[source]

combine values in track with newly parsed.

test_duplicate_category()[source]

try to add two categories to Track.

test_duplicate_public()[source]

try to set public via its property and additionally with change_keywords.

test_fences()[source]

Test fences.

test_fs_encoding()[source]

fs_encoding.

test_getitem()[source]

backend[idx].

test_header_changes()[source]

Only change things in _header_data. Assert that the full gpx is loaded before saving.

test_header_data()[source]

Test usage of Track._header_data.

test_id()[source]

id_in_backend must be str.

test_in()[source]

x in backend.

test_init()[source]

test initialisation.

test_key()[source]

Track.key().

test_keyword_args()[source]

‘Track.keywords’ must accept any variant of iterable.

test_last_time()[source]

Track.last_time.

test_local_keywords()[source]

Some keyword tests. More see in test_backends.

test_merge_partial_tracks()[source]

Test Track.merge(partial_tracks=True).

test_no_category()[source]

category must return default value if not present in gpx.keywords.

test_no_public()[source]

public must return False if not present in gpx.keywords.

test_one_line_per_trkpt()[source]

One line per trackpoint.

test_openrunner_point_encoding()[source]

Test Openrunner encoding/decoding of points.

test_overlapping_times()[source]

Track.overlapping_times(tracks).

test_parse()[source]

check for Track parsing xml correctly.

test_parse_objectname_directory()[source]

Test Backend.parse_objectname for directory.

test_parse_objectname_mmt()[source]

Test Backend.parse_objectname for MMT.

test_parse_objectname_serverdirectory()[source]

Test Backend.parse_objectname for serverdirectory.

test_points_equal()[source]

test Track.points_equal.

test_remove_category()[source]

remove category from Track.

test_remove_public()[source]

remove and add public from Track using remove_keywords and change_keywords.

test_remove_track()[source]

If a backend has several identical tracks, make sure we remove the right one.

test_repr()[source]

test __str__.

test_save()[source]

save locally.

test_save_dir()[source]

Correct files?.

Directory symlinks.

test_track_list()[source]

test list of tracks.

gpxity.backends.test.test_backends module

implements gpxity.backends.test.test_backends.TestBackends for all backends.

class gpxity.backends.test.test_backends.TestBackends(methodName='runTest')[source]

Bases: gpxity.backends.test.basic.BasicTest

Are the supported_ attributes set correctly?.

test_all_backends()[source]

Check if Backend.all_backend_classes works.

test_backend_dirty()[source]

track1._dirty.

test_can_decode_all_categories()[source]

Check if we can decode all backend categories.

test_can_encode_all_categories()[source]

Check if we can encode all internal categories to a given backend value for all backends.

test_category_map()[source]

Check if all backends can losslessly encode/decode all supported_categories.

This is done locally assuming that Backend.supported_categories is correct. test_legal_categories() tests Backend.supported_categories for correctness.

test_change_points()[source]

Can we change the points of a track?.

For MMT this means re-uploading and removing the previous instance, so this

is not always as trivial as it should be.

test_directory()[source]

directory creation/deletion.

test_directory_backend()[source]

Manipulate backend.

test_directory_dirty()[source]

test gpx._dirty where id_in_backend is not the default.

Currently track._dirty = ‘gpx’ changes the file name which is wrong.

test_download_many_from_mmt()[source]

Download many tracks.

test_duplicate_title()[source]

two tracks having the same title.

test_duplicate_tracks()[source]

What happens if we save the same track twice?.

test_keywords() → None[source]

Test arbitrary keyword changes.

Returns:None

Check if our fixed list of categories still matches the online service.

test_lifetrack()[source]

test life tracking against a local server.

test_long_description()[source]

Test long descriptions.

test_match()[source]

test backend match function.

Returns:None
test_merge_backends()[source]

merge backends.

test_mmt_empty()[source]

MMT refuses upload without a specific error message if there is no track point.

test_mmt_free_lifetrack()[source]

test life tracking against a free account on mapmytracks.com.

test_no_username()[source]

Some backends must fail if given no username.

test_open_wrong_password()[source]

Open backends with wrong password.

test_open_wrong_username()[source]

Open backends with username missing in auth.cfg.

test_private()[source]

Up- and download private tracks.

test_save_empty()[source]

Save empty track.

test_scan()[source]

some tests about Backend.scan().

test_setters()[source]

For all Track attributes with setters, test if we can change them without changing something else.

test_supported()[source]

Check values in supported for all backends.

test_write_remoteattr()[source]

If we change title, description, public, category in track, is the backend updated?.

test_z2_keywords()[source]

save and load keywords.

For now, all test keywords start with uppercase, avoiding MMT problems

test_z9_create_backend()[source]

Test creation of a backend.

test_z_unicode()[source]

Can we up- and download unicode characters in all text attributes?.

xtest_gpsies_bug()[source]

We have this bug only sometimes: title, category or time will be wrong in track2. Workaround is in GPSIES._edit.