Skip to content

Commit

Permalink
Merge pull request #16 from treee111/unit-tests-for-downloader
Browse files Browse the repository at this point in the history
Introduce Unittests & a lot of refactoring & pylint findings corrections
  • Loading branch information
treee111 authored Jul 4, 2021
2 parents c5ae987 + 4d7d59f commit e5a1957
Show file tree
Hide file tree
Showing 13 changed files with 501 additions and 183 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ output*/*
tools_dl/
venv/*

# in all folders
**/__pycache__/*

# common resources
common_resources/land-polygons-split-4326/
common_resources/land-polygons-split-4326.zip
common_resources/__pycache__/*
common_resources/*.pyc

# mac/unix
Expand Down
14 changes: 14 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[MESSAGES CONTROL]

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#enable=

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
disable=line-too-long

#import-error, wrong-import-position
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
"console": "integratedTerminal",
"args": ["${workspaceRoot}/common_resources/germany-only1.json"]
},
{
"name": "only2-tile",
"type": "python",
"request": "launch",
"program": "${workspaceRoot}/wahoo_map_creator.py",
"console": "integratedTerminal",
"args": ["${workspaceRoot}/common_resources/germany-only2.json"]
},
{
"name": "only5-tile",
"type": "python",
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Types of changes

- `Added` for new features.
- `Changed` for changes in existing functionality.
- `Deprecated` for soon-to-be removed features.
- `Removed` for now removed features.
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [Unreleased]
### Added
- unittests for downloader.py methods
### Changed
- pylint findings corrected
- a lot of refactored (focus methods)
- refactor downloader-methods for testing with unittests
- correctly check force_download and force_processing against boolean
- fix pylint findings (focus documentation and imports)
- reduce (double) imported standard modules & delete unused imports
- position of creation of empty directories in `output` folder

## [0.4.0] - 2021-07-01
### Added
Expand Down
3 changes: 3 additions & 0 deletions common_resources/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
constants
"""
#!/usr/bin/python

Translate_Country = {
Expand Down
17 changes: 15 additions & 2 deletions common_resources/constants_functions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""
functions and object for constants
"""
#!/usr/bin/python

# import official python packages
import sys

# import custom python packages
from os import sys, path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from common_resources import constants


def get_region_of_country(county):
"""
returns the region / continent of a given country
"""
region = ''
if county in constants.africa :
region = 'africa'
Expand All @@ -31,6 +36,10 @@ def get_region_of_country(county):


def get_geofabrik_region_of_country(input_county):
"""
returns the geofabrik region / continent of a given country
the geofabrik region is sometimes written different than the get_region_of_country() region
"""
# search for country match in geofabrik tables to determine region to use for map download
c_translated = translate_country_input_to_geofabrik(input_county)

Expand Down Expand Up @@ -63,6 +72,10 @@ def get_geofabrik_region_of_country(input_county):


def translate_country_input_to_geofabrik(county):
"""
translates the given country to the geofabrik country
the geofabrik country is sometimes written different
"""
# search for user entered country name in translated (to geofabrik). if match continue with matched else continue with user entered country

try:
Expand Down
Loading

0 comments on commit e5a1957

Please sign in to comment.