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
0832e046
Commit
0832e046
authored
5 months ago
by
Neda Moeini
Browse files
Options
Downloads
Patches
Plain Diff
Add unittests modify VRF WF
parent
9c502a20
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!314
Feature/vrf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/fixtures/__init__.py
+2
-0
2 additions, 0 deletions
test/fixtures/__init__.py
test/fixtures/vrf_fixtures.py
+45
-0
45 additions, 0 deletions
test/fixtures/vrf_fixtures.py
test/workflows/vrf/test_modify_vrf_router_list.py
+40
-0
40 additions, 0 deletions
test/workflows/vrf/test_modify_vrf_router_list.py
with
87 additions
and
0 deletions
test/fixtures/__init__.py
+
2
−
0
View file @
0832e046
...
@@ -15,6 +15,7 @@ from test.fixtures.router_fixtures import router_subscription_factory
...
@@ -15,6 +15,7 @@ from test.fixtures.router_fixtures import router_subscription_factory
from
test.fixtures.site_fixtures
import
site_subscription_factory
from
test.fixtures.site_fixtures
import
site_subscription_factory
from
test.fixtures.super_pop_switch_fixtures
import
super_pop_switch_subscription_factory
from
test.fixtures.super_pop_switch_fixtures
import
super_pop_switch_subscription_factory
from
test.fixtures.switch_fixtures
import
switch_subscription_factory
from
test.fixtures.switch_fixtures
import
switch_subscription_factory
from
test.fixtures.vrf_fixtures
import
vrf_subscription_factory
__all__
=
[
__all__
=
[
"
access_port_factory
"
,
"
access_port_factory
"
,
...
@@ -33,4 +34,5 @@ __all__ = [
...
@@ -33,4 +34,5 @@ __all__ = [
"
site_subscription_factory
"
,
"
site_subscription_factory
"
,
"
super_pop_switch_subscription_factory
"
,
"
super_pop_switch_subscription_factory
"
,
"
switch_subscription_factory
"
,
"
switch_subscription_factory
"
,
"
vrf_subscription_factory
"
,
]
]
This diff is collapsed.
Click to expand it.
test/fixtures/vrf_fixtures.py
0 → 100644
+
45
−
0
View file @
0832e046
import
pytest
from
orchestrator.db
import
db
from
orchestrator.domain
import
SubscriptionModel
from
orchestrator.types
import
SubscriptionLifecycle
from
pydantic_forms.types
import
UUIDstr
from
gso.products
import
ProductName
from
gso.products.product_types.vrf
import
VRFInactive
from
gso.services.subscriptions
import
get_product_id_by_name
@pytest.fixture
()
def
vrf_subscription_factory
(
faker
,
geant_partner
):
def
subscription_create
(
partner
:
dict
|
None
=
None
,
description
:
str
|
None
=
None
,
start_date
:
str
|
None
=
"
2024-01-01T10:20:30+01:02
"
,
vrf_name
:
str
|
None
=
None
,
route_distinguisher
:
str
|
None
=
None
,
route_target
:
str
|
None
=
None
,
vrf_as_number
:
int
|
None
=
None
,
status
:
SubscriptionLifecycle
|
None
=
None
,
)
->
UUIDstr
:
if
partner
is
None
:
partner
=
geant_partner
product_id
=
get_product_id_by_name
(
ProductName
.
VRF
)
vrf_subscription
=
VRFInactive
.
from_product_id
(
product_id
,
customer_id
=
partner
[
"
partner_id
"
],
insync
=
True
)
vrf_subscription
.
vrf
.
vrf_name
=
vrf_name
or
faker
.
pystr
()
vrf_subscription
.
vrf
.
route_distinguisher
=
route_distinguisher
or
faker
.
pystr
()
vrf_subscription
.
vrf
.
route_target
=
route_target
or
faker
.
pystr
()
vrf_subscription
.
vrf
.
vrf_as_number
=
vrf_as_number
or
faker
.
pyint
()
vrf_subscription
=
SubscriptionModel
.
from_other_lifecycle
(
vrf_subscription
,
SubscriptionLifecycle
.
ACTIVE
)
vrf_subscription
.
description
=
description
or
f
"
VRF
{
vrf_subscription
.
vrf
.
vrf_name
}
"
vrf_subscription
.
start_date
=
start_date
if
status
:
vrf_subscription
.
status
=
status
vrf_subscription
.
save
()
db
.
session
.
commit
()
return
str
(
vrf_subscription
.
subscription_id
)
return
subscription_create
This diff is collapsed.
Click to expand it.
test/workflows/vrf/test_modify_vrf_router_list.py
0 → 100644
+
40
−
0
View file @
0832e046
import
uuid
import
pytest
from
pydantic_forms.exceptions
import
FormValidationError
from
gso.products.product_types.vrf
import
VRF
from
test.workflows
import
assert_complete
,
extract_state
,
run_workflow
@pytest.mark.workflow
()
def
test_modify_vrf_router_list
(
vrf_subscription_factory
,
router_subscription_factory
,
faker
):
subscription_id
=
vrf_subscription_factory
()
initial_vrf_data
=
[
{
"
subscription_id
"
:
subscription_id
},
{
"
router_list
"
:
[{
"
router_id
"
:
router_subscription_factory
()},
{
"
router_id
"
:
router_subscription_factory
()}],
},
]
result
,
_
,
_
=
run_workflow
(
"
modify_vrf_router_list
"
,
initial_vrf_data
)
assert_complete
(
result
)
state
=
extract_state
(
result
)
subscription_id
=
state
[
"
subscription_id
"
]
subscription
=
VRF
.
from_subscription
(
subscription_id
)
assert
subscription
.
status
==
"
active
"
assert
len
(
subscription
.
vrf
.
vrf_router_list
)
==
2
@pytest.mark.workflow
()
def
test_modify_vrf_router_list_with_invalid_router_id
(
vrf_subscription_factory
,
router_subscription_factory
,
faker
):
subscription_id
=
vrf_subscription_factory
()
initial_vrf_data
=
[
{
"
subscription_id
"
:
subscription_id
},
{
"
router_list
"
:
[{
"
router_id
"
:
uuid
.
uuid4
()}],
},
]
with
pytest
.
raises
(
FormValidationError
,
match
=
"
Input should be an instance of Select a router
"
):
run_workflow
(
"
modify_vrf_router_list
"
,
initial_vrf_data
)
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