FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mapillary-python-sdk/tests/utils/test_filter.py at main · mapillary/mapillary-python-sdk · GitHub
mapillary
/
mapillary-python-sdk
Public
Notifications
You must be signed in to change notification settings
Fork
23
Star
66
Code
Issues
17
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
mapillary-python-sdk
/
tests
/
utils
/
test_filter.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
99 lines (79 loc) · 2.75 KB
Breadcrumbs
mapillary-python-sdk
/
tests
/
utils
/
test_filter.py
Copy path
File metadata and controls
99 lines (79 loc) · 2.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
# -*- coding: utf-8 -*-
"""
tests.utils.test_filter
~~~~~~~~~~~~~~~~~~~~~~~~
For testing the functions under mapillary/utils/filter.py
:copyright: (c) 2021 Facebook
:license: MIT LICENSE
"""
# Package imports
import
pytest
import
logging
# Logger
# Local imports
from
mapillary
.
utils
.
filter
import
pipeline
# Pipeline
from
tests
.
conftest
import
data
# Data as fixture
logger
=
logging
.
getLogger
(
__name__
)
@
pytest
.
mark
.
parametrize
(
"operation, expected"
,
[(
"pipeline(data=fetched_data, components=[...]"
,
"len(data['features'])"
)],
)
def
test_pipeline_min_captured_at
(
data
:
dict
,
operation
,
expected
):
# Operation to test
test_that
=
f"len(
{
operation
}
) !=
{
expected
}
"
# Logging the intended operation to be tested
logger
.
info
(
f"
\n
[test_pipeline_min_captured_at] Test that
{
test_that
}
"
)
# Get data from data fixture
fetched_data
,
_
,
longitude
,
latitude
=
data
.
values
()
# Pass through pipeline. Actual data on left, operation on right
actual
=
pipeline
(
data
=
fetched_data
,
components
=
[
{
"filter"
:
"haversine_dist"
,
"radius"
:
5000
,
"coords"
: [
longitude
,
latitude
],
},
{
"filter"
:
"min_captured_at"
,
"min_timestamp"
:
"2020-01-01"
,
},
],
)
# What was expected left, what was actual on the right
assert
(
len
(
actual
)
!=
len
(
fetched_data
[
"features"
])
or
len
(
fetched_data
[
"features"
])
==
0
),
f"
{
test_that
}
failed, got
{
actual
}
"
@
pytest
.
mark
.
parametrize
(
"operation, expected"
,
[(
"pipeline(data=fetched_data, components=[...]"
,
"len(data['features'])"
)],
)
def
test_pipeline_haversine_dist
(
data
:
dict
,
operation
,
expected
):
# Operation to test
test_that
=
f"len(
{
operation
}
) !=
{
expected
}
"
# Logging the intended operation to be tested
logger
.
info
(
f"
\n
[test_pipeline_haversine_dist] Test that
{
test_that
}
"
)
# Get data from data fixture
fetched_data
,
_
,
longitude
,
latitude
=
data
.
values
()
# Pass through pipeline. Actual data on left, operation on right
actual
=
pipeline
(
data
=
fetched_data
,
components
=
[
{
"filter"
:
"haversine_dist"
,
"radius"
:
5000
,
"coords"
: [
longitude
,
latitude
],
},
{
"filter"
:
"haversine_dist"
,
"radius"
:
1000
,
"coords"
: [
longitude
,
latitude
],
},
],
)
# What was expected left, what was actual on the right
assert
(
len
(
actual
)
!=
len
(
fetched_data
[
"features"
])
or
len
(
fetched_data
[
"features"
])
==
0
),
f"
{
test_that
}
failed, got
{
actual
}
"
Back
|
FazBrowse Home
|
New Git URL