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
2cf2bbd9
Commit
2cf2bbd9
authored
1 year ago
by
Hakan Calim
Browse files
Options
Downloads
Patches
Plain Diff
NAT-286 adjusted tests for netbox client to merge from develop
parent
3fe41c67
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
#84242
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
+7
-22
7 additions, 22 deletions
test/services/test_netbox.py
with
7 additions
and
22 deletions
test/services/test_netbox.py
+
7
−
22
View file @
2cf2bbd9
...
...
@@ -8,7 +8,7 @@ from unittest.mock import patch, Mock
import
pytest
from
pynetbox.core.response
import
Record
from
gso.services.netbox_client
import
Net
B
oxClient
from
gso.services.netbox_client
import
Net
b
oxClient
from
gso.products.product_blocks.site
import
SiteTier
from
gso.utils.exceptions
import
WorkflowStateError
...
...
@@ -41,7 +41,7 @@ def site():
@pytest.fixture
(
scope
=
"
module
"
)
def
device_bay
():
values
=
{
"
id
"
:
1
,
"
name
"
:
"
test123
"
}
values
=
{
"
id
"
:
1
,
"
name
"
:
"
bay_test
"
,
"
position
"
:
1
}
return
Record
(
values
,
None
,
None
)
...
...
@@ -62,21 +62,6 @@ 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
,
...
...
@@ -99,7 +84,7 @@ def test_create_device(mock_api,
mock_api
.
return_value
.
dcim
.
module_types
.
get
.
return_value
=
card_type
mock_api
.
return_value
.
dcim
.
module_types
.
create
.
return_value
=
card_type
new_device
=
Net
B
oxClient
().
create_device
(
device_name
,
site_tier
)
new_device
=
Net
b
oxClient
().
create_device
(
device_name
,
site_tier
)
assert
new_device
is
not
None
assert
new_device
.
name
==
device_name
...
...
@@ -120,7 +105,7 @@ def test_get_available_lags(mock_api, mock_from_subscription, data_config_filena
mock_router
=
mock_subscription
.
router
mock_router
.
router_fqdn
=
"
test_router
"
netbox_client
=
Net
B
oxClient
()
netbox_client
=
Net
b
oxClient
()
result
=
netbox_client
.
get_available_lags
(
router_id
)
# Check the result of the function
...
...
@@ -134,7 +119,7 @@ def test_create_interface(mock_api, device, interface, data_config_filename: Pat
mock_api
.
return_value
.
dcim
.
interfaces
.
create
.
return_value
=
interface
# Create new interface
new_interface
=
Net
B
oxClient
().
create_interface
(
interface
.
name
,
new_interface
=
Net
b
oxClient
().
create_interface
(
interface
.
name
,
interface
.
type
,
interface
.
speed
,
device
.
name
)
...
...
@@ -162,7 +147,7 @@ def test_reserve_interface_exception(mock_api, device, interface, data_config_fi
# Check exception
with
pytest
.
raises
(
WorkflowStateError
)
as
test_exception
:
Net
B
oxClient
().
reserve_interface
(
device
.
name
,
interface
.
name
)
Net
b
oxClient
().
reserve_interface
(
device
.
name
,
interface
.
name
)
assert
str
(
test_exception
.
value
)
==
exception_message
...
...
@@ -184,7 +169,7 @@ def test_reserve_interface(mock_api, device, interface, data_config_filename: Pa
interface
.
save
=
mock_save
# Check reservation of interface
updated_interface
=
Net
B
oxClient
().
reserve_interface
(
device
.
name
,
interface
.
name
)
updated_interface
=
Net
b
oxClient
().
reserve_interface
(
device
.
name
,
interface
.
name
)
assert
updated_interface
is
not
None
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