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.

assertBackendLength(backend, length)[source]

Check length of backend.

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

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

Parameters

xml – if True, also compare xml()

assertHasKeywords(gpxfile, expected)[source]

MMT shows keywords on the website lowercase but internally it capitalizes them.

assertNotEqualTracks(gpxfile1, gpxfile2, msg=None, with_category: bool = True)[source]

both gpxfiles 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 gpxfiles.

assertTrackFileContains(gpxfile, 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(backend_class=None, count: int = 1, idx: int = 0, category: str = None, public: bool = False, start_time=None, end_time=None)[source]

create a GpxFile.

It starts off with test.gpx and appends a last gpxfile 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 gpxfiles, they all go in a different direction clockwise, with an angle in degrees of 360 * idx / count.

Parameters
  • backend_class – If given, use it as source for a random category

  • 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 gpxfile. Default: if count == len(GpxFile.categories), the default value will be backend_class.supported_categories[idx]. Otherwise a random value from backend_class.supported_categories will be applied.

  • public – should the gpxfiles 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 gpxfile not bound to a backend

Return type

(GpxFile)

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 DirectoryAccount.prefix.

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

set up an instance of a backend with count gpxfiles.

If count == len(GpxFile.categories), the list of gpxfiles 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, only for Directory

  • count – how many random gpxfiles should be inserted?

  • clear_first – if True, first remove all existing gpxfiles. None: do if the backend supports it.

  • category – The wanted category, one out of GpxFile.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 GpxFile.categories

  • public – should the gpxfiles be public or private? Default is False. Exception: MMT with subscription free has default True

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=True, clear_first=None, category=None, public: bool = None, test_name=None)[source]

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

temp_directory(url=None, count=0, cleanup=True, clear_first=None, category=None, public: bool = None, test_name=None)[source]

Temp directory backend.

test_passwd = 'pwd'
tst_backend(backend_cls, subtest=None)[source]

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

gpxity.backends.test.test_track module

implements test classes for GpxFile.

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

gpxfile tests.

parse_objectnames(cases)[source]

Helper for test_parse_objectname.

test_add_points()[source]

test GpxFile.add_points.

test_adjust_time()[source]

adjust_time().

test_all_backend_classes()[source]

Test Backend.all_backend_classes.

test_angle()[source]

test GpxFile.angle.

test_clone()[source]

True if the clone is identical.

test_combine()[source]

combine values in gpxfile with newly parsed.

test_duplicate_category()[source]

try to add two categories to GpxFile.

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]

Change fields loaded by gpxfile scan, before _load_full() is done.

test_header_data()[source]

Test usage of GpxFile._header_data.

test_in()[source]

x in backend.

test_init()[source]

test initialisation.

test_key()[source]

GpxFile.key().

test_keyword_args()[source]

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

test_last_time()[source]

GpxFile.last_time.

test_local_keywords()[source]

Some keyword tests. More see in test_backends.

test_merge_partial_tracks()[source]

Test GpxFile.merge(partial=True).

test_merge_track()[source]

Check if everything is correctly merged.

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]

GpxFile.overlapping_times(gpxfiles).

test_parse()[source]

check for GpxFile parsing xml correctly.

test_parse_objectname_directory()[source]

Test Backend.parse_objectname for directory.

test_parse_objectname_other()[source]

Test Backend.parse_objectname for other than Directory.

test_points_equal()[source]

test GpxFile.points_equal.

test_remove_category()[source]

remove category from GpxFile.

test_remove_public()[source]

remove and add public from GpxFile using remove_keywords and change_keywords.

test_remove_track()[source]

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

test_repr()[source]

test __str__.

test_save()[source]

save locally.

test_save_dir()[source]

Correct files?.

test_split_segments()[source]

Test GpxFile.split_segments.

Directory symlinks.

test_track_list()[source]

test list of gpxfiles.

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_account_none()[source]

Test access with Account=None.

test_all_backends()[source]

Check if Backend.all_backend_classes works.

test_backend_dirty()[source]

gpxfile1._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 gpxfile?.

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 gpxfile._dirty = ‘gpx’ changes the file name which is wrong.

test_download_many_from_mmt()[source]

Download many gpxfiles.

test_duplicate_gpxfiles()[source]

What happens if we save the same gpxfile twice?.

test_duplicate_title()[source]

two gpxfiles having the same title.

test_id_change()[source]

id_in_backend must be legal.

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 gpxfile point.

test_open_wrong_password()[source]

Open backends with wrong password.

test_open_wrong_username()[source]

Open backends with username missing in Account.

test_private()[source]

Up- and download private gpxfiles.

test_rewrite_empty()[source]

Remove all points and rewrite a gpxfile.

test_save_empty()[source]

Save empty gpxfile.

test_scan()[source]

some tests about Backend.scan().

test_setters()[source]

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

test_subscription()[source]

Test backend.subscription.

test_supported()[source]

Check values in supported for all backends.

test_write_category()[source]

If we change category in gpxfile, is the backend updated?.

test_write_public()[source]

If we change public in gpxfile, is the backend updated?.

test_write_remoteattr()[source]

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

test_z2_keywords()[source]

save and load keywords.

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 gpxfile2. Workaround is in GPSIES._edit.