Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dynamic Exposure
OpenBuildingMap
rabotnik-obm
Commits
5f4a1124
Commit
5f4a1124
authored
Sep 09, 2021
by
Marius Kriegerowski
Browse files
fix tests
parent
6b072fa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
rabotnikobm/rules/gem_occupancy/get_building_occupancy.py
View file @
5f4a1124
...
...
@@ -19,7 +19,6 @@
from
__future__
import
annotations
import
logging
import
csv
from
typing
import
Optional
from
rabotnik
import
Rule
from
rabotnik.storages.base
import
StorageBase
...
...
@@ -52,7 +51,7 @@ class OverridingOccupancy:
for
candidate
in
self
.
mapping
.
keys
():
if
candidate
in
occupancies
.
tags
:
raise
TagResult
(
GEMTag
(
candidate
)
)
raise
TagResult
(
candidate
)
@
classmethod
def
from_csv
(
cls
,
fn
:
str
)
->
OverridingOccupancy
:
...
...
@@ -61,6 +60,8 @@ class OverridingOccupancy:
with
open
(
fn
)
as
csvfile
:
occupancy_mapping
=
{
k
.
strip
():
v
.
strip
()
for
(
k
,
v
)
in
csv
.
reader
(
csvfile
)}
occupancy_mapping
=
{
GEMTag
.
from_string
(
k
):
v
for
k
,
v
in
occupancy_mapping
.
items
()}
return
cls
(
mapping
=
occupancy_mapping
)
...
...
tests/test_get_gem_occupancy.py
View file @
5f4a1124
...
...
@@ -48,8 +48,12 @@ async def test_rule_get_building_occupancy(storage_consumer, building_poi_mapper
def
test_overriding_occupancy
(
overriding_occupancies
):
"""Rule #1"""
demo_tags
=
TagStatistics
.
from_strings
([
"ASS1"
,
"COM10"
])
occupancy
=
overriding_occupancies
.
apply
(
demo_tags
)
assert
occupancy
==
"COM10"
try
:
occupancy
=
overriding_occupancies
.
apply
(
demo_tags
)
except
TagResult
as
e
:
occupancy
=
e
.
tag
assert
occupancy
==
GEMTag
.
from_string
(
"COM10"
)
def
test_overriding_occupancy_unknown
(
overriding_occupancies
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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