Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mapping Provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
Next Generation Map
Mapping Provider
Commits
e23c01c6
Commit
e23c01c6
authored
1 month ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
template service build
parent
1eacadd4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mapping_provider/backends/services.py
+13
-13
13 additions, 13 deletions
mapping_provider/backends/services.py
test/conftest.py
+14
-3
14 additions, 3 deletions
test/conftest.py
with
27 additions
and
16 deletions
mapping_provider/backends/services.py
+
13
−
13
View file @
e23c01c6
...
...
@@ -33,15 +33,6 @@ class Service(BaseModel):
endpoints
:
list
[
Endpoint
]
overlays
:
Overlays
@classmethod
def
from_inprov_service
(
cls
,
service
:
dict
[
str
,
Any
])
->
'
Service
'
:
return
cls
(
sid
=
service
[
'
sid
'
],
name
=
service
[
'
name
'
],
type
=
service
[
'
type
'
],
endpoints
=
list
(
map
(
Endpoint
.
from_inprov_endpoint
,
service
[
'
endpoints
'
])),
overlays
=
Overlays
.
from_inprov_overlays
(
service
[
'
overlays
'
]),
)
class
ServiceList
(
BaseModel
):
services
:
list
[
Service
]
...
...
@@ -53,13 +44,22 @@ def _services() -> Generator[Service, None, None]:
scid_current
=
cache
.
get
(
inventory
.
REPORTING_SCID_CURRENT_CACHE_FILENAME
)
poller_interfaces
=
cache
.
get
(
inventory
.
INPROV_POLLER_INTERFACES_CACHE_FILENAME
)
correlator_state
=
cache
.
get
(
correlator
.
CACHED_CORRELATOR_STATE_FILENAME
)
except
IO
Error
:
except
FileNotFound
Error
:
logger
.
exception
(
'
not enough data available to build the service list
'
)
return
# for service in cache.get(INPROV_MAP_SERVICES_CACHE_FILENAME):
# yield Service.from_inprov_service(service)
for
service
in
inprov_map_services
:
overlays
=
Overlays
(
speed
=
service
[
'
overlays
'
][
'
speed
'
])
endpoints
=
list
(
map
(
Endpoint
.
from_inprov_endpoint
,
service
[
'
endpoints
'
]))
yield
Service
(
sid
=
service
[
'
sid
'
],
name
=
service
[
'
name
'
],
type
=
service
[
'
type
'
],
endpoints
=
endpoints
,
overlays
=
overlays
,
)
def
build_service_info_list
()
->
ServiceList
:
return
ServiceList
(
services
=
[]
)
return
ServiceList
(
services
=
_services
()
)
This diff is collapsed.
Click to expand it.
test/conftest.py
+
14
−
3
View file @
e23c01c6
...
...
@@ -7,7 +7,8 @@ import pytest
from
fastapi.testclient
import
TestClient
from
mapping_provider
import
create_app
from
mapping_provider.backends
import
cache
from
mapping_provider.backends
import
cache
,
inventory
,
correlator
from
.common
import
load_test_data
@pytest.fixture
...
...
@@ -44,8 +45,18 @@ def dummy_config_filename(dummy_config):
@pytest.fixture
def
client
(
dummy_config_filename
):
os
.
environ
[
'
SETTINGS_FILENAME
'
]
=
dummy_config_filename
with
patch
(
'
sentry_sdk.init
'
)
as
_mock_sentry_init
:
return
TestClient
(
create_app
())
with
tempfile
.
TemporaryDirectory
()
as
tmp_dir
:
cache
.
init
(
tmp_dir
)
# there's no rmq in config, so workers won't start
cache
.
set
(
inventory
.
INPROV_MAP_SERVICES_CACHE_FILENAME
,
load_test_data
(
'
inprov-services.json
'
))
cache
.
set
(
inventory
.
REPORTING_SCID_CURRENT_CACHE_FILENAME
,
load_test_data
(
'
scid-current.json
'
))
cache
.
set
(
inventory
.
INPROV_POLLER_INTERFACES_CACHE_FILENAME
,
load_test_data
(
'
poller-interfaces.json
'
))
cache
.
set
(
correlator
.
CACHED_CORRELATOR_STATE_FILENAME
,
load_test_data
(
'
correlator-state.json
'
))
with
patch
(
'
sentry_sdk.init
'
)
as
_mock_sentry_init
:
yield
TestClient
(
create_app
())
@pytest.fixture
(
autouse
=
True
)
def
run_around_tests
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment