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
(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
-
mysql_docker_name
= 'gpxitytest_mysql'¶
-
mysql_ip_address
= None¶
-
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 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, 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
-
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'¶
-
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.
-
test_duplicate_public
()[source]¶ try to set public via its property and additionally with change_keywords.
-
test_remove_public
()[source]¶ remove and add public from GpxFile 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 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_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_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 gpxfile point.
-
test_setters
()[source]¶ For all GpxFile attributes with setters, test if we can change them without changing something else.
-