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
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
f0774e61
Commit
f0774e61
authored
1 year ago
by
Hakan Calim
Browse files
Options
Downloads
Patches
Plain Diff
NAT-286: fixed problem in test_interface_reservation
parent
65ead28f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!89
Feature/nat 286 create unit tests for netbox client
Pipeline
#84240
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
+22
-4
22 additions, 4 deletions
test/services/test_netbox.py
with
22 additions
and
4 deletions
test/services/test_netbox.py
+
22
−
4
View file @
f0774e61
...
...
@@ -4,7 +4,7 @@ Unit tests for testing the netbox client
import
uuid
from
os
import
PathLike
from
unittest.mock
import
patch
from
unittest.mock
import
patch
,
Mock
import
pytest
from
pynetbox.core.response
import
Record
...
...
@@ -62,6 +62,21 @@ def interface():
return
Record
(
values
,
None
,
None
)
@pytest.fixture
(
scope
=
"
module
"
)
def
app
():
app
=
Mock
()
app
.
token
=
"
abc123
"
app
.
base_url
=
"
http://localhost:8080/testing/api
"
return
app
@pytest.fixture
(
scope
=
"
module
"
)
def
endpoint
():
endpoint
=
Mock
()
endpoint
.
name
=
"
test-endpoint
"
return
endpoint
@patch
(
"
gso.services.netbox_client.pynetbox.api
"
)
def
test_create_device
(
mock_api
,
device
,
...
...
@@ -158,15 +173,18 @@ def test_reserve_interface(mock_api, device, interface, data_config_filename: Pa
"""
# Set interface to not reserved
interface
.
enabled
=
False
interface
.
api
=
mock_api
# Mock netbox api
mock_api
.
return_value
.
dcim
.
devices
.
get
.
return_value
=
device
mock_api
.
return_value
.
dcim
.
interfaces
.
get
.
return_value
=
interface
mock_api
.
return_value
.
dcim
.
interfaces
.
save
.
return_value
=
interface
# mock save method
mock_save
=
Mock
()
mock_save
.
save
.
return_value
=
interface
interface
.
save
=
mock_save
# Check reservation of interface
updated_interface
=
NetBoxClient
().
reserve_interface
(
device
.
name
,
interface
.
name
)
assert
updated_interface
is
not
None
assert
updated_interface
.
enabled
is
not
True
assert
updated_interface
.
enabled
is
True
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