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
047f4f44
Commit
047f4f44
authored
1 year ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Fixed test issue.
parent
9f4a6fba
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!94
Feature/Netbox integration terminate ip trunk
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/workflows/iptrunk/test_terminate_iptrunk.py
+17
-22
17 additions, 22 deletions
test/workflows/iptrunk/test_terminate_iptrunk.py
with
17 additions
and
22 deletions
test/workflows/iptrunk/test_terminate_iptrunk.py
+
17
−
22
View file @
047f4f44
...
...
@@ -32,41 +32,32 @@ class MockedNetboxClient:
return
self
.
BaseMockObject
(
id
=
1
,
name
=
"
test
"
)
@pytest.fixture
def
netbox_client_mock
():
# Mock NetboxClient methods
with
(
patch
(
"
gso.services.netbox_client.NetboxClient.get_device_by_name
"
)
as
mock_get_device_by_name
,
patch
(
"
gso.services.netbox_client.NetboxClient.get_interface_by_name_and_by_device_id
"
)
as
mock_get_interface_by_name_and_by_device_id
,
patch
(
"
gso.services.netbox_client.NetboxClient.delete_interface
"
)
as
mock_delete_interface
,
patch
(
"
gso.services.netbox_client.NetboxClient.free_interface
"
)
as
mock_free_interface
,
):
mock_get_device_by_name
.
return_value
=
MockedNetboxClient
().
get_device_by_name
()
mock_get_interface_by_name_and_by_device_id
.
return_value
=
(
MockedNetboxClient
().
get_interface_by_name_and_by_device_id
()
)
mock_delete_interface
.
return_value
=
MockedNetboxClient
().
delete_interface
()
mock_free_interface
.
return_value
=
MockedNetboxClient
().
free_interface
()
yield
@pytest.mark.workflow
@patch
(
"
gso.workflows.iptrunk.terminate_iptrunk.provisioning_proxy.provision_ip_trunk
"
)
@patch
(
"
gso.workflows.iptrunk.terminate_iptrunk.provisioning_proxy.deprovision_ip_trunk
"
)
@patch
(
"
gso.workflows.iptrunk.terminate_iptrunk.infoblox.delete_network
"
)
@patch
(
"
gso.services.netbox_client.NetboxClient.get_device_by_name
"
)
@patch
(
"
gso.services.netbox_client.NetboxClient.get_interface_by_name_and_by_device_id
"
)
@patch
(
"
gso.services.netbox_client.NetboxClient.delete_interface
"
)
@patch
(
"
gso.services.netbox_client.NetboxClient.free_interface
"
)
def
test_iptrunk_modify_isis_metric_success
(
mocked_free_interface
,
mocked_delete_interface
,
mocked_get_interface_by_name_and_by_device_id
,
mocked_get_device_by_name
,
mock_infoblox_delete_network
,
mock_deprovision_ip_trunk
,
mock_provision_ip_trunk
,
iptrunk_subscription_factory
,
faker
,
netbox_client_mock
,
):
# Set up mock return values
product_id
=
iptrunk_subscription_factory
()
mocked_netbox
=
MockedNetboxClient
()
mocked_get_device_by_name
.
return_value
=
mocked_netbox
.
get_device_by_name
()
mocked_get_interface_by_name_and_by_device_id
.
return_value
=
mocked_netbox
.
get_interface_by_name_and_by_device_id
()
mocked_delete_interface
.
return_value
=
mocked_netbox
.
delete_interface
()
mocked_free_interface
.
return_value
=
mocked_netbox
.
free_interface
()
# Run workflow
initial_iptrunk_data
=
[
...
...
@@ -95,6 +86,10 @@ def test_iptrunk_modify_isis_metric_success(
assert_complete
(
result
)
# Check NetboxClient calls
assert
mocked_delete_interface
.
call_count
==
2
# once for each side
assert
mocked_free_interface
.
call_count
==
4
# Free interfaces for each side(2 per side)
state
=
extract_state
(
result
)
subscription_id
=
state
[
"
subscription_id
"
]
subscription
=
Iptrunk
.
from_subscription
(
subscription_id
)
...
...
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