Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
Get Baden-Württemberg CityGML Opendata
Commits
e136c0f2
Commit
e136c0f2
authored
10 months ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Writing more tests
parent
47f08468
master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
requirements.txt
+1
-0
requirements.txt
test_zipcode.py
+43
-1
test_zipcode.py
with
44 additions
and
1 deletion
+44
-1
requirements.txt
+
1
-
0
View file @
e136c0f2
...
...
@@ -2,3 +2,4 @@ pyproj
requests
pyperclip
tqdm
shapely
This diff is collapsed.
Click to expand it.
test_zipcode.py
+
43
-
1
View file @
e136c0f2
import
unittest
import
pyperclip
from
get_coordinates_by_zipcode
import
get_coordinates_by_zipcode
class
TestGetCoordinates
(
unittest
.
TestCase
):
def
test_get_
mohringen
(
self
):
def
test_get_
single_plz
(
self
):
coords
=
get_coordinates_by_zipcode
([
'70567'
])
self
.
assertTrue
(
coords
.
startswith
(
'POLYGON ((9.'
))
self
.
assertTrue
(
' 48.7'
in
coords
)
self
.
assertTrue
(
' 9.15'
in
coords
)
def
test_get_multiple_plz
(
self
):
# Multiple PLZs
coords
=
get_coordinates_by_zipcode
([
'70567'
,
'70569'
])
self
.
assertTrue
(
coords
.
startswith
(
'POLYGON ((9.'
))
self
.
assertTrue
(
' 48.7'
in
coords
)
self
.
assertTrue
(
' 9.15'
in
coords
)
def
test_get_multiple_disjoint_plz
(
self
):
# Multiple PLZs, separate
coords
=
get_coordinates_by_zipcode
([
'70567'
,
'10178'
])
self
.
assertTrue
(
coords
.
startswith
(
'MULTIPOLYGON ((('
))
self
.
assertTrue
(
' 48.7'
in
coords
)
self
.
assertTrue
(
' 9.15'
in
coords
)
self
.
assertTrue
(
' 52.5'
in
coords
)
self
.
assertTrue
(
' 13.4'
in
coords
)
def
test_get_plz_with_hole
(
self
):
# 70469 missing in the middle
coords
=
get_coordinates_by_zipcode
([
'70469'
,
'70193'
,
'70176'
,
'70174'
,
'70191'
])
self
.
assertTrue
(
coords
.
startswith
(
'POLYGON ((9'
))
self
.
assertTrue
(
'), ('
in
coords
)
def
test_get_coords_in_clipboard
(
self
):
pyperclip
.
copy
(
""
)
self
.
assertEquals
(
pyperclip
.
paste
(),
""
)
get_coordinates_by_zipcode
([
'70567'
])
coords
=
pyperclip
.
paste
()
self
.
assertTrue
(
coords
.
startswith
(
'POLYGON ((9.'
))
self
.
assertTrue
(
' 48.7'
in
coords
)
self
.
assertTrue
(
' 9.15'
in
coords
)
def
test_get_unknown_plz
(
self
):
# Incorrect PLZ
self
.
assertRaisesRegex
(
AttributeError
,
"no information could be found"
,
get_coordinates_by_zipcode
,
[
'1234567'
]
)
if
__name__
==
'__main__'
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets