Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-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
dashboardv3
inventory-provider
Commits
3ac3ca2a
Commit
3ac3ca2a
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
sql-enabled opsdb query tests
parent
b74fdb40
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_opsdb_queries.py
+56
-0
56 additions, 0 deletions
test/test_opsdb_queries.py
with
56 additions
and
0 deletions
test/test_opsdb_queries.py
0 → 100644
+
56
−
0
View file @
3ac3ca2a
import
os
import
pytest
from
inventory_provider.db
import
db
from
inventory_provider.db
import
opsdb
pytestmark
=
pytest
.
mark
.
skipif
(
'
TEST_OPSDB_HOSTNAME
'
not
in
os
.
environ
,
reason
=
'
TEST_OPSDB_HOSTNAME environment variable not found
'
)
pytestmark
=
pytest
.
mark
.
skipif
(
'
TEST_OPSDB_DBNAME
'
not
in
os
.
environ
,
reason
=
'
TEST_OPSDB_DBNAME environment variable not found
'
)
pytestmark
=
pytest
.
mark
.
skipif
(
'
TEST_OPSDB_USERNAME
'
not
in
os
.
environ
,
reason
=
'
TEST_OPSDB_USERNAME environment variable not found
'
)
pytestmark
=
pytest
.
mark
.
skipif
(
'
TEST_OPSDB_PASSWORD
'
not
in
os
.
environ
,
reason
=
'
TEST_OPSDB_PASSWORD environment variable not found
'
)
DB_PARAMS
=
{
"
hostname
"
:
"
test-opsdb02.geant.net
"
,
# "hostname": "prod-opsdb01.geant.net",
"
dbname
"
:
"
opsdb
"
,
"
username
"
:
"
opsro
"
,
"
password
"
:
"
opsro
"
}
@pytest.fixture
def
db_params
():
return
{
'
hostname
'
:
os
.
environ
[
'
TEST_OPSDB_HOSTNAME
'
],
'
dbname
'
:
os
.
environ
[
'
TEST_OPSDB_DBNAME
'
],
'
username
'
:
os
.
environ
[
'
TEST_OPSDB_USERNAME
'
],
'
password
'
:
os
.
environ
[
'
TEST_OPSDB_PASSWORD
'
],
}
@pytest.fixture
def
connection
(
db_params
):
with
db
.
connection
(
DB_PARAMS
)
as
c
:
yield
c
@pytest.mark.parametrize
(
'
equipment,card,port
'
,
[
(
'
grv3.lon.uk.geant.net
'
,
'
1-1
'
,
'
3
'
),
(
'
grv3.lon.uk.geant.net
'
,
'
1-1
'
,
'
5
'
),
# ('grv2.ams.nl.geant.net', '1-1', '1'),
(
'
grv3.lon.uk.geant.net
'
,
'
1-1
'
,
'
1
'
),
])
def
test_query
(
connection
,
equipment
,
card
,
port
):
circuit
=
opsdb
.
get_coriant_path
(
connection
,
equipment
,
card
,
port
)
from
pprint
import
pprint
pprint
(
circuit
)
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