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
ffb0e264
Commit
ffb0e264
authored
10 months ago
by
Karel van Klink
Committed by
Neda Moeini
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Speed up import unit test by mocking redundant sleeps
parent
0154217a
No related branches found
Branches containing commit
Tags
2.0
Tags containing commit
1 merge request
!139
Feature/add validation workflows
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cli/test_imports.py
+24
-12
24 additions, 12 deletions
test/cli/test_imports.py
with
24 additions
and
12 deletions
test/cli/test_imports.py
+
24
−
12
View file @
ffb0e264
...
...
@@ -199,20 +199,23 @@ def opengear_data(temp_file, faker, site_subscription_factory):
###########
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_iptrunk_success
(
mock_start_process
,
iptrunk_data
):
def
test_import_iptrunk_success
(
mock_start_process
,
mock_sleep
,
iptrunk_data
):
import_iptrunks
(
iptrunk_data
()[
"
path
"
])
assert
mock_start_process
.
call_count
==
1
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_site_success
(
mock_start_process
,
site_data
):
def
test_import_site_success
(
mock_start_process
,
mock_sleep
,
site_data
):
import_sites
(
site_data
()[
"
path
"
])
assert
mock_start_process
.
call_count
==
1
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_site_twice
(
mock_start_process
,
site_data
,
site_subscription_factory
,
capfd
):
def
test_import_site_twice
(
mock_start_process
,
mock_sleep
,
site_data
,
site_subscription_factory
,
capfd
):
site_import_data
=
site_data
()
# Create an initial site
site_subscription_factory
(
...
...
@@ -236,8 +239,9 @@ def test_import_site_twice(mock_start_process, site_data, site_subscription_fact
assert
mock_start_process
.
call_count
==
0
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_site_with_invalid_data
(
mock_start_process
,
site_data
,
capfd
):
def
test_import_site_with_invalid_data
(
mock_start_process
,
mock_sleep
,
site_data
,
capfd
):
# invalid data, missing site_latitude and invalid site_longitude
incorrect_site_data
=
site_data
(
site_latitude
=
None
,
site_longitude
=
"
broken
"
)
...
...
@@ -259,14 +263,16 @@ def test_import_site_with_invalid_data(mock_start_process, site_data, capfd):
assert
mock_start_process
.
call_count
==
0
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_router_success
(
mock_start_process
,
site_subscription_factory
,
router_data
):
def
test_import_router_success
(
mock_start_process
,
mock_sleep
,
site_subscription_factory
,
router_data
):
import_routers
(
router_data
()[
"
path
"
])
assert
mock_start_process
.
call_count
==
1
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_router_with_invalid_data
(
mock_start_process
,
router_data
,
capfd
):
def
test_import_router_with_invalid_data
(
mock_start_process
,
mock_sleep
,
router_data
,
capfd
):
broken_data
=
router_data
(
hostname
=
""
,
router_lo_ipv6_address
=
"
Not an IP address
"
)
import_routers
(
broken_data
[
"
path
"
])
...
...
@@ -281,14 +287,16 @@ router_lo_ipv6_address
assert
mock_start_process
.
call_count
==
0
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_iptrunk_successful
(
mock_start_process
,
iptrunk_data
):
def
test_import_iptrunk_successful
(
mock_start_process
,
mock_sleep
,
iptrunk_data
):
import_iptrunks
(
iptrunk_data
()[
"
path
"
])
assert
mock_start_process
.
call_count
==
1
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_iptrunk_invalid_router_id_side_a_and_b
(
mock_start_process
,
iptrunk_data
,
capfd
):
def
test_import_iptrunk_invalid_router_id_side_a_and_b
(
mock_start_process
,
mock_sleep
,
iptrunk_data
,
capfd
):
broken_data
=
iptrunk_data
(
side_a_node
=
"
Doesn
'
t exist
"
,
side_b_node
=
"
Also doesn
'
t exist
"
)
import_iptrunks
(
broken_data
[
"
path
"
])
...
...
@@ -305,8 +313,9 @@ side_b_node_id
assert
mock_start_process
.
call_count
==
0
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_iptrunk_non_unique_members_side_a_and_b
(
mock_start_process
,
iptrunk_data
,
faker
,
capfd
):
def
test_import_iptrunk_non_unique_members_side_a_and_b
(
mock_start_process
,
mock_sleep
,
iptrunk_data
,
faker
,
capfd
):
duplicate_interface
=
{
"
interface_name
"
:
faker
.
network_interface
(),
"
interface_description
"
:
faker
.
sentence
()}
side_a_members
=
[
duplicate_interface
for
_
in
range
(
5
)]
side_b_members
=
[
duplicate_interface
for
_
in
range
(
5
)]
...
...
@@ -328,8 +337,9 @@ def test_import_iptrunk_non_unique_members_side_a_and_b(mock_start_process, iptr
assert
mock_start_process
.
call_count
==
0
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_iptrunk_side_a_member_count_mismatch
(
mock_start_process
,
iptrunk_data
,
faker
,
capfd
):
def
test_import_iptrunk_side_a_member_count_mismatch
(
mock_start_process
,
mock_sleep
,
iptrunk_data
,
faker
,
capfd
):
side_a_members
=
[
{
"
interface_name
"
:
faker
.
network_interface
(),
"
interface_description
"
:
faker
.
sentence
()}
for
_
in
range
(
5
)
]
...
...
@@ -348,14 +358,16 @@ def test_import_iptrunk_side_a_member_count_mismatch(mock_start_process, iptrunk
assert
mock_start_process
.
call_count
==
0
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_office_router_success
(
mock_start_process
,
office_router_data
):
def
test_import_office_router_success
(
mock_start_process
,
mock_sleep
,
office_router_data
):
import_office_routers
(
office_router_data
()[
"
path
"
])
assert
mock_start_process
.
call_count
==
1
@patch
(
"
gso.cli.imports.time.sleep
"
)
@patch
(
"
gso.cli.imports.start_process
"
)
def
test_import_super_pop_switch_success
(
mock_start_process
,
super_pop_switch_data
):
def
test_import_super_pop_switch_success
(
mock_start_process
,
mock_sleep
,
super_pop_switch_data
):
import_super_pop_switches
(
super_pop_switch_data
()[
"
path
"
])
assert
mock_start_process
.
call_count
==
1
...
...
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