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
-
mysql_docker_name
= 'gpxitytest_mysql'¶
-
mysql_ip_address
= None¶
-
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 seeTestBackends.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
-
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'¶
-
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_duplicate_public
()[source]¶ try to set public via its property and additionally with change_keywords.
-
test_header_changes
()[source]¶ Only change things in _header_data. Assert that the full gpx is loaded before saving.
-
test_remove_public
()[source]¶ remove and add public from Track using remove_keywords and change_keywords.
-
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_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_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_legal_categories
()[source]¶ Check if our fixed list of categories still matches the online service.
-
test_mmt_empty
()[source]¶ MMT refuses upload without a specific error message if there is no track point.
-
test_setters
()[source]¶ For all Track attributes with setters, test if we can change them without changing something else.
-
test_write_remoteattr
()[source]¶ If we change title, description, public, category in track, is the backend updated?.
-