Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
54198aff
Commit
54198aff
authored
1 year ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Added sample test.
parent
42f445d9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!89
Feature/nat 286 create unit tests for netbox client
Pipeline
#84221
failed
1 year ago
Stage: tox
Stage: documentation
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/services/test_netbox.py
+24
-0
24 additions, 0 deletions
test/services/test_netbox.py
with
24 additions
and
0 deletions
test/services/test_netbox.py
+
24
−
0
View file @
54198aff
...
...
@@ -3,6 +3,7 @@ Unit tests for testing the netbox client
"""
import
os
import
json
import
uuid
from
os
import
PathLike
from
unittest.mock
import
patch
...
...
@@ -65,3 +66,26 @@ def test_create_device(data_config_filename: PathLike):
result
=
NetBoxClient
().
create_device
(
device_name
,
site_tier
)
assert
result
is
not
None
@patch
(
"
gso.services.netbox_client.Router.from_subscription
"
)
@patch
(
"
gso.services.netbox_client.pynetbox.api
"
)
def
test_get_available_lags
(
mock_api
,
mock_from_subscription
,
data_config_filename
:
PathLike
):
router_id
=
uuid
.
uuid4
()
feasible_lags
=
[
f
"
LAG-
{
i
}
"
for
i
in
range
(
1
,
10
)]
# Mock the pynetbox API instance
mock_netbox
=
mock_api
.
return_value
mock_filter
=
mock_netbox
.
dcim
.
interfaces
.
filter
mock_filter
.
return_value
=
[{
"
name
"
:
f
"
LAG-
{
i
}
"
,
"
type
"
:
"
lag
"
}
for
i
in
range
(
1
,
4
)]
# Mock the Router.from_subscription method
mock_subscription
=
mock_from_subscription
.
return_value
mock_router
=
mock_subscription
.
router
mock_router
.
router_fqdn
=
"
test_router
"
netbox_client
=
NetBoxClient
()
result
=
netbox_client
.
get_available_lags
(
router_id
)
# Check the result of the function
assert
result
==
[
lag
for
lag
in
feasible_lags
if
lag
not
in
[
f
"
LAG-
{
i
}
"
for
i
in
range
(
1
,
4
)]]
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