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
3965d8a3
Verified
Commit
3965d8a3
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
Use pytest marker for workflows
parent
6d89fe55
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!203
Use pytest marker for workflows
Pipeline
#86633
failed
1 year ago
Stage: tox
Stage: documentation
Stage: sonarqube
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cli/test_imports.py
+18
-15
18 additions, 15 deletions
test/cli/test_imports.py
with
18 additions
and
15 deletions
test/cli/test_imports.py
+
18
−
15
View file @
3965d8a3
import
json
import
time
from
pathlib
import
Path
import
pytest
...
...
@@ -187,23 +186,21 @@ def office_router_data(temp_file, faker, site_subscription_factory):
###########
@pytest.mark.workflow
()
def
test_import_iptrunk_success
(
iptrunk_data
):
assert
len
(
get_active_iptrunk_subscriptions
())
==
0
import_iptrunks
(
iptrunk_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_IP_TRUNK
]))
==
0
assert
len
(
get_active_iptrunk_subscriptions
())
==
1
@pytest.mark.workflow
()
def
test_import_site_success
(
site_data
):
assert
SubscriptionTable
.
query
.
all
()
==
[]
mock_site_data
=
site_data
()
import_sites
(
mock_site_data
[
"
path
"
])
time
.
sleep
(
1
)
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_SITE
]))
==
0
subscription
=
retrieve_subscription_by_subscription_instance_value
(
resource_type
=
"
site_name
"
,
value
=
mock_site_data
[
"
data
"
][
"
site_name
"
]
...
...
@@ -211,13 +208,13 @@ def test_import_site_success(site_data):
assert
subscription
is
not
None
@pytest.mark.workflow
()
def
test_import_site_twice
(
site_data
,
capfd
):
path_location
=
site_data
()[
"
path
"
]
import_sites
(
path_location
)
# Second identical import should print ValidationError to stdout
import_sites
(
path_location
)
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
(
"""
Validation error: 4 validation errors for SiteImportModel
...
...
@@ -234,6 +231,7 @@ site_name
assert
SubscriptionTable
.
query
.
count
()
==
1
@pytest.mark.workflow
()
def
test_import_site_with_invalid_data
(
site_data
,
capfd
):
# invalid data, missing site_latitude and invalid site_longitude
incorrect_site_data
=
site_data
(
site_latitude
=
None
,
site_longitude
=
"
broken
"
)
...
...
@@ -241,7 +239,6 @@ def test_import_site_with_invalid_data(site_data, capfd):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_sites
(
incorrect_site_data
[
"
path
"
])
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
(
"""
Validation error: 2 validation errors for SiteImportModel
...
...
@@ -254,18 +251,20 @@ site_longitude
assert
SubscriptionTable
.
query
.
count
()
==
0
@pytest.mark.workflow
()
def
test_import_router_success
(
site_subscription_factory
,
router_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_routers
(
router_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
len
(
get_active_router_subscriptions
())
==
1
@pytest.mark.workflow
()
def
test_import_router_with_invalid_data
(
router_data
,
capfd
):
broken_data
=
router_data
(
hostname
=
""
,
router_lo_ipv6_address
=
"
Not an IP address
"
)
import_routers
(
broken_data
[
"
path
"
])
# Only a Site has been added, no Router
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
1
out
,
_
=
capfd
.
readouterr
()
# The extra space at the end of the next line is required, and not dangling by accident.
...
...
@@ -277,18 +276,20 @@ def test_import_router_with_invalid_data(router_data, capfd):
)
@pytest.mark.workflow
()
def
test_import_iptrunk_successful
(
iptrunk_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_iptrunks
(
iptrunk_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
5
assert
len
(
get_active_iptrunk_subscriptions
())
==
1
@pytest.mark.workflow
()
def
test_import_iptrunk_invalid_router_id_side_a_and_b
(
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
"
])
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
SubscriptionTable
.
query
.
count
()
==
4
assert
len
(
get_active_iptrunk_subscriptions
())
==
0
...
...
@@ -302,6 +303,7 @@ side_b_node_id
)
@pytest.mark.workflow
()
def
test_import_iptrunk_non_unique_members_side_a_and_b
(
iptrunk_data
,
faker
,
capfd
):
duplicate_interface
=
{
"
interface_name
"
:
faker
.
network_interface
(),
"
interface_description
"
:
faker
.
sentence
()}
side_a_members
=
[
duplicate_interface
for
_
in
range
(
5
)]
...
...
@@ -309,7 +311,6 @@ def test_import_iptrunk_non_unique_members_side_a_and_b(iptrunk_data, faker, cap
broken_data
=
iptrunk_data
(
side_a_members
=
side_a_members
,
side_b_members
=
side_b_members
)
import_iptrunks
(
broken_data
[
"
path
"
])
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
SubscriptionTable
.
query
.
count
()
==
4
assert
len
(
get_active_iptrunk_subscriptions
())
==
0
...
...
@@ -323,6 +324,7 @@ side_b_ae_members
)
@pytest.mark.workflow
()
def
test_import_iptrunk_side_a_member_count_mismatch
(
iptrunk_data
,
faker
,
capfd
):
side_a_members
=
[
{
"
interface_name
"
:
faker
.
network_interface
(),
"
interface_description
"
:
faker
.
sentence
()}
for
_
in
range
(
5
)
...
...
@@ -332,7 +334,6 @@ def test_import_iptrunk_side_a_member_count_mismatch(iptrunk_data, faker, capfd)
]
broken_data
=
iptrunk_data
(
side_a_members
=
side_a_members
,
side_b_members
=
side_b_members
)
import_iptrunks
(
broken_data
[
"
path
"
])
time
.
sleep
(
1
)
out
,
_
=
capfd
.
readouterr
()
assert
SubscriptionTable
.
query
.
count
()
==
4
...
...
@@ -345,19 +346,21 @@ __root__
)
@pytest.mark.workflow
()
def
test_import_office_router_success
(
office_router_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_office_routers
(
office_router_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
2
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_OFFICE_ROUTER
]))
==
0
assert
len
(
get_subscriptions
([
ProductType
.
OFFICE_ROUTER
]))
==
1
@pytest.mark.workflow
()
def
test_import_super_pop_switch_success
(
super_pop_switch_data
):
assert
SubscriptionTable
.
query
.
count
()
==
0
import_super_pop_switches
(
super_pop_switch_data
()[
"
path
"
])
time
.
sleep
(
1
)
assert
SubscriptionTable
.
query
.
count
()
==
2
assert
len
(
get_subscriptions
([
ProductType
.
IMPORTED_SUPER_POP_SWITCH
]))
==
0
assert
len
(
get_subscriptions
([
ProductType
.
SUPER_POP_SWITCH
]))
==
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