Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LSO
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
LSO
Commits
474f4537
Verified
Commit
474f4537
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
replace mocked values in tests using faker methods
parent
56267560
No related branches found
No related tags found
1 merge request
!46
replace mocked values in tests using faker methods
Pipeline
#84140
passed
1 year ago
Stage: tox
Stage: documentation
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
requirements.txt
+1
-0
1 addition, 0 deletions
requirements.txt
test/conftest.py
+9
-3
9 additions, 3 deletions
test/conftest.py
test/routes/test_ip_trunk.py
+146
-135
146 additions, 135 deletions
test/routes/test_ip_trunk.py
test/routes/test_router.py
+14
-13
14 additions, 13 deletions
test/routes/test_router.py
with
170 additions
and
151 deletions
requirements.txt
+
1
−
0
View file @
474f4537
...
@@ -20,6 +20,7 @@ dictdiffer~=0.9.0
...
@@ -20,6 +20,7 @@ dictdiffer~=0.9.0
jmespath
~=1.0.1
jmespath
~=1.0.1
pytest
~=7.4.0
pytest
~=7.4.0
Faker
~=19.3.1
responses
~=0.23.1
responses
~=0.23.1
sphinx
sphinx
sphinx-rtd-theme
sphinx-rtd-theme
...
...
This diff is collapsed.
Click to expand it.
test/conftest.py
+
9
−
3
View file @
474f4537
...
@@ -4,6 +4,7 @@ import tempfile
...
@@ -4,6 +4,7 @@ import tempfile
from
typing
import
Any
,
Generator
from
typing
import
Any
,
Generator
import
pytest
import
pytest
from
faker
import
Faker
from
fastapi.testclient
import
TestClient
from
fastapi.testclient
import
TestClient
import
lso
import
lso
...
@@ -11,13 +12,13 @@ import lso
...
@@ -11,13 +12,13 @@ import lso
TEST_CONFIG
=
{
"
collection-name
"
:
"
kvklink.echo
"
,
"
test-role
"
:
"
kvklink.echo.echo_uptime
"
}
TEST_CONFIG
=
{
"
collection-name
"
:
"
kvklink.echo
"
,
"
test-role
"
:
"
kvklink.echo.echo_uptime
"
}
@pytest.fixture
@pytest.fixture
(
scope
=
"
session
"
)
def
config_data
()
->
dict
[
str
,
str
]:
def
config_data
()
->
dict
[
str
,
str
]:
"""
Start the server with valid configuration data.
"""
"""
Start the server with valid configuration data.
"""
return
{
"
ansible_playbooks_root_dir
"
:
"
/
"
}
return
{
"
ansible_playbooks_root_dir
"
:
"
/
"
}
@pytest.fixture
@pytest.fixture
(
scope
=
"
session
"
)
def
config_file
(
config_data
:
dict
[
str
,
str
])
->
Generator
[
str
,
Any
,
None
]:
def
config_file
(
config_data
:
dict
[
str
,
str
])
->
Generator
[
str
,
Any
,
None
]:
"""
Fixture that will yield a filename that contains a valid configuration.
"""
Fixture that will yield a filename that contains a valid configuration.
...
@@ -29,9 +30,14 @@ def config_file(config_data: dict[str, str]) -> Generator[str, Any, None]:
...
@@ -29,9 +30,14 @@ def config_file(config_data: dict[str, str]) -> Generator[str, Any, None]:
yield
file
.
name
yield
file
.
name
@pytest.fixture
@pytest.fixture
(
scope
=
"
session
"
)
def
client
(
config_file
:
str
)
->
Generator
[
TestClient
,
Any
,
None
]:
def
client
(
config_file
:
str
)
->
Generator
[
TestClient
,
Any
,
None
]:
"""
Return a client that can be used to test the server.
"""
"""
Return a client that can be used to test the server.
"""
os
.
environ
[
"
SETTINGS_FILENAME
"
]
=
config_file
os
.
environ
[
"
SETTINGS_FILENAME
"
]
=
config_file
app
=
lso
.
create_app
()
app
=
lso
.
create_app
()
yield
TestClient
(
app
)
# wait here until calling context ends
yield
TestClient
(
app
)
# wait here until calling context ends
@pytest.fixture
(
scope
=
"
session
"
)
def
faker
()
->
Faker
:
return
Faker
(
locale
=
"
en_GB
"
)
This diff is collapsed.
Click to expand it.
test/routes/test_ip_trunk.py
+
146
−
135
View file @
474f4537
...
@@ -2,151 +2,162 @@ import time
...
@@ -2,151 +2,162 @@ import time
from
unittest.mock
import
patch
from
unittest.mock
import
patch
import
jsonschema
import
jsonschema
import
pytest
import
responses
import
responses
from
faker
import
Faker
from
starlette.testclient
import
TestClient
from
starlette.testclient
import
TestClient
from
lso.playbook
import
PlaybookLaunchResponse
from
lso.playbook
import
PlaybookLaunchResponse
from
test.routes
import
TEST_CALLBACK_URL
,
test_ansible_runner_run
from
test.routes
import
TEST_CALLBACK_URL
,
test_ansible_runner_run
_SUBSCRIPTION_OBJECT
=
{
"
subscription_id
"
:
"
0
"
,
@pytest.fixture
(
scope
=
"
session
"
)
"
de
scription
"
:
"
IP trunk, geant_s_sid:GS-00000
"
,
def
sub
scription
_object
(
faker
:
Faker
)
->
dict
:
"
iptrunk
"
:
{
return
{
"
geant_s_sid
"
:
"
GS-00000
"
,
"
subscription_id
"
:
faker
.
pyint
()
,
"
iptrunk_
description
"
:
"
A description for this trunk
"
,
"
description
"
:
"
IP trunk, geant_s_sid:GS-00000
"
,
"
iptrunk
_isis_metric
"
:
9000
,
"
iptrunk
"
:
{
"
iptrunk_minimum_links
"
:
1
,
"
geant_s_sid
"
:
"
GS-00000
"
,
"
iptrunk_
si
des
"
:
[
"
iptrunk_des
cription
"
:
faker
.
pystr
(),
{
"
iptrunk_isis_metric
"
:
faker
.
pyint
(),
"
name
"
:
"
IptrunkSideBlock
"
,
"
iptrunk_minimum_links
"
:
1
,
"
label
"
:
None
,
"
iptrunk_sides
"
:
[
"
iptrunk_side_node
"
:
{
{
"
name
"
:
"
Router
Block
"
,
"
name
"
:
"
IptrunkSide
Block
"
,
"
label
"
:
None
,
"
label
"
:
None
,
"
router_fqdn
"
:
"
rt1.city.country.geant.net
"
,
"
iptrunk_side_node
"
:
{
"
router_role
"
:
"
p
"
,
"
name
"
:
"
RouterBlock
"
,
"
router_site
"
:
{
"
name
"
:
"
SiteBlock
"
,
"
label
"
:
None
,
"
label
"
:
None
,
"
site_city
"
:
"
City
"
,
"
router_fqdn
"
:
"
rt1.city.country.geant.net
"
,
"
site_name
"
:
"
city
"
,
"
router_role
"
:
"
p
"
,
"
site_tier
"
:
"
1
"
,
"
router_site
"
:
{
"
site_country
"
:
"
Country
"
,
"
name
"
:
"
SiteBlock
"
,
"
site_latitude
"
:
1
,
"
label
"
:
None
,
"
site_longitude
"
:
1
,
"
site_city
"
:
faker
.
city
(),
"
site_ts_address
"
:
"
0.0.0.0
"
,
"
site_name
"
:
"
city
"
,
"
site_internal_id
"
:
1
,
"
site_tier
"
:
"
1
"
,
"
site_country_code
"
:
"
xxx
"
,
"
site_country
"
:
faker
.
country
(),
"
owner_subscription_id
"
:
"
b5146e62-da79-4791-b703-d03b0ebeebf8
"
,
"
site_latitude
"
:
float
(
faker
.
latitude
()),
"
site_bgp_community_id
"
:
1
,
"
site_longitude
"
:
float
(
faker
.
longitude
()),
"
subscription_instance_id
"
:
"
039e03e5-5c09-4236-8d28-cd569e04315e
"
,
"
site_ts_address
"
:
faker
.
ipv4
(),
"
site_internal_id
"
:
faker
.
pyint
(),
"
site_country_code
"
:
faker
.
country_code
(),
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
site_bgp_community_id
"
:
faker
.
pyint
(),
"
subscription_instance_id
"
:
faker
.
uuid4
(),
},
"
router_vendor
"
:
"
juniper
"
,
"
router_ts_port
"
:
faker
.
pyint
(),
"
router_access_via_ts
"
:
faker
.
pybool
(),
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
router_lo_iso_address
"
:
"
49.51e5.0001.0620.4009.6014.00
"
,
"
router_lo_ipv4_address
"
:
faker
.
ipv4
(),
"
router_lo_ipv6_address
"
:
faker
.
ipv6
(),
"
router_si_ipv4_network
"
:
faker
.
ipv4
()
+
"
/31
"
,
"
router_is_ias_connected
"
:
faker
.
pybool
(),
"
subscription_instance_id
"
:
faker
.
uuid4
(),
"
router_ias_lt_ipv4_network
"
:
faker
.
ipv4
()
+
"
/31
"
,
"
router_ias_lt_ipv6_network
"
:
faker
.
ipv6
()
+
"
/126
"
,
},
},
"
router_vendor
"
:
"
juniper
"
,
"
iptrunk_side_ae_iface
"
:
"
ae1
"
,
"
router_ts_port
"
:
22222
,
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
router_access_via_ts
"
:
True
,
"
iptrunk_side_ae_members
"
:
[
"
ge-0/0/0
"
,
"
ge-0/0/1
"
],
"
owner_subscription_id
"
:
"
4a0001f1-459d-46f5-9a85-b8177e1bbc1b
"
,
"
subscription_instance_id
"
:
faker
.
uuid4
(),
"
router_lo_iso_address
"
:
"
49.51e5.0001.0620.4009.6014.00
"
,
"
iptrunk_side_ae_geant_a_sid
"
:
"
SID-11112
"
,
"
router_lo_ipv4_address
"
:
"
0.0.0.0
"
,
"
iptrunk_side_ae_members_description
"
:
[
faker
.
pystr
(),
faker
.
pystr
()],
"
router_lo_ipv6_address
"
:
"
::
"
,
"
router_si_ipv4_network
"
:
"
0.0.0.0/31
"
,
"
router_is_ias_connected
"
:
True
,
"
subscription_instance_id
"
:
"
2242883e-a581-4ce1-919c-9c986ded57f6
"
,
"
router_ias_lt_ipv4_network
"
:
"
0.0.0.0/31
"
,
"
router_ias_lt_ipv6_network
"
:
"
::/126
"
,
},
},
"
iptrunk_side_ae_iface
"
:
"
ae1
"
,
{
"
owner_subscription_id
"
:
"
c9ddbe14-e107-4749-82ac-e22091cdb132
"
,
"
name
"
:
"
IptrunkSideBlock
"
,
"
iptrunk_side_ae_members
"
:
[
"
ge-0/0/0
"
,
"
ge-0/0/1
"
],
"
subscription_instance_id
"
:
"
6276fac5-9d31-4c9a-9247-48f02a19f151
"
,
"
iptrunk_side_ae_geant_a_sid
"
:
"
SID-11112
"
,
"
iptrunk_side_ae_members_description
"
:
[
"
first one
"
,
"
second one
"
],
},
{
"
name
"
:
"
IptrunkSideBlock
"
,
"
label
"
:
None
,
"
iptrunk_side_node
"
:
{
"
name
"
:
"
RouterBlock
"
,
"
label
"
:
None
,
"
label
"
:
None
,
"
router_fqdn
"
:
"
rt2.city.country.geant.net
"
,
"
iptrunk_side_node
"
:
{
"
router_role
"
:
"
p
"
,
"
name
"
:
"
RouterBlock
"
,
"
router_site
"
:
{
"
name
"
:
"
SiteBlock
"
,
"
label
"
:
None
,
"
label
"
:
None
,
"
site_city
"
:
"
City
"
,
"
router_fqdn
"
:
"
rt1.city.country.geant.net
"
,
"
site_name
"
:
"
city
"
,
"
router_role
"
:
"
p
"
,
"
site_tier
"
:
"
1
"
,
"
router_site
"
:
{
"
site_country
"
:
"
Country
"
,
"
name
"
:
"
SiteBlock
"
,
"
site_latitude
"
:
1
,
"
label
"
:
None
,
"
site_longitude
"
:
1
,
"
site_city
"
:
faker
.
city
(),
"
site_ts_address
"
:
"
0.0.0.0
"
,
"
site_name
"
:
"
city
"
,
"
site_internal_id
"
:
2
,
"
site_tier
"
:
"
1
"
,
"
site_country_code
"
:
"
country
"
,
"
site_country
"
:
faker
.
country
(),
"
owner_subscription_id
"
:
"
93cba8dc-7424-44c0-8872-13159df93042
"
,
"
site_latitude
"
:
float
(
faker
.
latitude
()),
"
site_bgp_community_id
"
:
2
,
"
site_longitude
"
:
float
(
faker
.
longitude
()),
"
subscription_instance_id
"
:
"
6bf4f274-6496-438d-9dba-9c3984d0ec07
"
,
"
site_ts_address
"
:
faker
.
ipv4
(),
"
site_internal_id
"
:
faker
.
pyint
(),
"
site_country_code
"
:
faker
.
country_code
(),
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
site_bgp_community_id
"
:
faker
.
pyint
(),
"
subscription_instance_id
"
:
faker
.
uuid4
(),
},
"
router_vendor
"
:
"
juniper
"
,
"
router_ts_port
"
:
faker
.
pyint
(),
"
router_access_via_ts
"
:
faker
.
pybool
(),
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
router_lo_iso_address
"
:
"
49.51e5.0001.0620.4009.6014.00
"
,
"
router_lo_ipv4_address
"
:
faker
.
ipv4
(),
"
router_lo_ipv6_address
"
:
faker
.
ipv6
(),
"
router_si_ipv4_network
"
:
faker
.
ipv4
()
+
"
/31
"
,
"
router_is_ias_connected
"
:
faker
.
pybool
(),
"
subscription_instance_id
"
:
faker
.
uuid4
(),
"
router_ias_lt_ipv4_network
"
:
faker
.
ipv4
()
+
"
/31
"
,
"
router_ias_lt_ipv6_network
"
:
faker
.
ipv6
()
+
"
/126
"
,
},
},
"
router_vendor
"
:
"
juniper
"
,
"
iptrunk_side_ae_iface
"
:
"
ae1
"
,
"
router_ts_port
"
:
11111
,
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
router_access_via_ts
"
:
True
,
"
iptrunk_side_ae_members
"
:
[
"
ge-0/0/0
"
,
"
ge-0/0/1
"
],
"
owner_subscription_id
"
:
"
9cb1fc7d-9608-42ce-aacc-2a97f9620a91
"
,
"
subscription_instance_id
"
:
faker
.
uuid4
(),
"
router_lo_iso_address
"
:
"
49.51e5.0001.0620.4009.6066.00
"
,
"
iptrunk_side_ae_geant_a_sid
"
:
"
SID-11112
"
,
"
router_lo_ipv4_address
"
:
"
0.0.0.0
"
,
"
iptrunk_side_ae_members_description
"
:
[
faker
.
pystr
(),
faker
.
pystr
()],
"
router_lo_ipv6_address
"
:
"
::
"
,
"
router_si_ipv4_network
"
:
"
0.0.0.0/31
"
,
"
router_is_ias_connected
"
:
True
,
"
subscription_instance_id
"
:
"
6d09394e-658b-4e55-8b1f-8b812d59f5a1
"
,
"
router_ias_lt_ipv4_network
"
:
"
0.0.0.0/31
"
,
"
router_ias_lt_ipv6_network
"
:
"
::/126
"
,
},
},
"
iptrunk_side_ae_iface
"
:
"
ae1
"
,
],
"
owner_subscription_id
"
:
"
c9ddbe14-e107-4749-82ac-e22091cdb132
"
,
"
iptrunk_side_ae_members
"
:
[
"
ge-0/0/0
"
,
"
ge-0/0/1
"
],
},
],
},
"
status
"
:
"
provisioning
"
,
}
_MIGRATION_OBJECT
=
{
"
new_node
"
:
{
"
description
"
:
"
Router rt1.luc.it.geant.net
"
,
"
router
"
:
{
"
router_access_via_ts
"
:
"
true
"
,
"
router_fqdn
"
:
"
rt1.luc.it.geant.net
"
,
"
router_role
"
:
"
pe
"
,
"
router_is_ias_connected
"
:
"
false
"
,
"
router_lo_ipv4_address
"
:
"
62.40.96.7
"
,
"
router_lo_ipv6_address
"
:
"
2001:798:aa:1::49
"
,
"
router_lo_iso_address
"
:
"
49.51e5.0001.0620.4009.6007.00
"
,
"
router_site
"
:
{
"
name
"
:
"
SiteBlock
"
,
"
label
"
:
"
null
"
,
"
site_city
"
:
"
Lucca
"
,
"
site_name
"
:
"
luc
"
,
"
site_tier
"
:
"
1
"
,
"
site_country
"
:
"
Italy
"
,
"
site_latitude
"
:
"
10.0
"
,
"
site_longitude
"
:
"
43.0
"
,
"
site_ts_address
"
:
"
172.16.100.151
"
,
"
site_internal_id
"
:
133
,
"
site_country_code
"
:
"
IT
"
,
"
owner_subscription_id
"
:
"
f4bacf38-39bb-4553-8e74-190699bd9b4e
"
,
"
site_bgp_community_id
"
:
33
,
"
subscription_instance_id
"
:
"
2cf443a2-4039-4402-ab75-73ff1a1096f5
"
,
},
"
router_ts_port
"
:
22111
,
"
router_vendor
"
:
"
juniper
"
,
},
},
"
status
"
:
"
provisioning
"
,
"
status
"
:
"
provisioning
"
,
},
}
"
new_lag_interface
"
:
"
ae1
"
,
"
new_lag_member_interfaces
"
:
[
"
ge-0/0/0
"
,
"
ge-0/0/1
"
],
"
replace_index
"
:
0
,
@pytest.fixture
(
scope
=
"
session
"
)
}
def
migration_object
(
faker
:
Faker
)
->
dict
:
return
{
"
new_node
"
:
{
"
description
"
:
"
Router rt1.luc.it.geant.net
"
,
"
router
"
:
{
"
router_access_via_ts
"
:
"
true
"
,
"
router_fqdn
"
:
"
rt1.luc.it.geant.net
"
,
"
router_role
"
:
"
pe
"
,
"
router_is_ias_connected
"
:
faker
.
pybool
(),
"
router_lo_ipv4_address
"
:
faker
.
ipv4
(),
"
router_lo_ipv6_address
"
:
faker
.
ipv6
(),
"
router_lo_iso_address
"
:
"
49.51e5.0001.0620.4009.6007.00
"
,
"
router_site
"
:
{
"
name
"
:
"
SiteBlock
"
,
"
label
"
:
"
null
"
,
"
site_city
"
:
faker
.
city
(),
"
site_name
"
:
"
luc
"
,
"
site_tier
"
:
"
1
"
,
"
site_country
"
:
faker
.
country
(),
"
site_latitude
"
:
"
10.0
"
,
"
site_longitude
"
:
"
43.0
"
,
"
site_ts_address
"
:
faker
.
ipv4
(),
"
site_internal_id
"
:
faker
.
pyint
(),
"
site_country_code
"
:
faker
.
country_code
(),
"
owner_subscription_id
"
:
faker
.
uuid4
(),
"
site_bgp_community_id
"
:
faker
.
pyint
(),
"
subscription_instance_id
"
:
faker
.
uuid4
(),
},
"
router_ts_port
"
:
faker
.
pyint
(),
"
router_vendor
"
:
"
juniper
"
,
},
"
status
"
:
"
provisioning
"
,
},
"
new_lag_interface
"
:
"
ae1
"
,
"
new_lag_member_interfaces
"
:
[
"
ge-0/0/0
"
,
"
ge-0/0/1
"
],
"
replace_index
"
:
0
,
}
@responses.activate
@responses.activate
def
test_ip_trunk_provisioning
(
client
:
TestClient
)
->
None
:
def
test_ip_trunk_provisioning
(
client
:
TestClient
,
subscription_object
:
dict
)
->
None
:
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
params
=
{
params
=
{
...
@@ -156,7 +167,7 @@ def test_ip_trunk_provisioning(client: TestClient) -> None:
...
@@ -156,7 +167,7 @@ def test_ip_trunk_provisioning(client: TestClient) -> None:
"
dry_run
"
:
True
,
"
dry_run
"
:
True
,
"
object
"
:
"
trunk_interface
"
,
"
object
"
:
"
trunk_interface
"
,
"
verb
"
:
"
deploy
"
,
"
verb
"
:
"
deploy
"
,
"
subscription
"
:
_SUBSCRIPTION_OBJECT
,
"
subscription
"
:
subscription_object
,
}
}
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
...
@@ -173,7 +184,7 @@ def test_ip_trunk_provisioning(client: TestClient) -> None:
...
@@ -173,7 +184,7 @@ def test_ip_trunk_provisioning(client: TestClient) -> None:
@responses.activate
@responses.activate
def
test_ip_trunk_modification
(
client
:
TestClient
)
->
None
:
def
test_ip_trunk_modification
(
client
:
TestClient
,
subscription_object
:
dict
)
->
None
:
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
params
=
{
params
=
{
...
@@ -182,8 +193,8 @@ def test_ip_trunk_modification(client: TestClient) -> None:
...
@@ -182,8 +193,8 @@ def test_ip_trunk_modification(client: TestClient) -> None:
"
tt_number
"
:
"
TT123456789
"
,
"
tt_number
"
:
"
TT123456789
"
,
"
dry_run
"
:
True
,
"
dry_run
"
:
True
,
"
verb
"
:
"
modify
"
,
"
verb
"
:
"
modify
"
,
"
subscription
"
:
_SUBSCRIPTION_OBJECT
,
"
subscription
"
:
subscription_object
,
"
old_subscription
"
:
_SUBSCRIPTION_OBJECT
,
"
old_subscription
"
:
subscription_object
,
}
}
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
...
@@ -200,7 +211,7 @@ def test_ip_trunk_modification(client: TestClient) -> None:
...
@@ -200,7 +211,7 @@ def test_ip_trunk_modification(client: TestClient) -> None:
@responses.activate
@responses.activate
def
test_ip_trunk_deletion
(
client
:
TestClient
)
->
None
:
def
test_ip_trunk_deletion
(
client
:
TestClient
,
subscription_object
:
dict
)
->
None
:
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
params
=
{
params
=
{
...
@@ -209,7 +220,7 @@ def test_ip_trunk_deletion(client: TestClient) -> None:
...
@@ -209,7 +220,7 @@ def test_ip_trunk_deletion(client: TestClient) -> None:
"
tt_number
"
:
"
TT123456789
"
,
"
tt_number
"
:
"
TT123456789
"
,
"
dry_run
"
:
True
,
"
dry_run
"
:
True
,
"
verb
"
:
"
terminate
"
,
"
verb
"
:
"
terminate
"
,
"
subscription
"
:
_SUBSCRIPTION_OBJECT
,
"
subscription
"
:
subscription_object
,
}
}
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
...
@@ -226,7 +237,7 @@ def test_ip_trunk_deletion(client: TestClient) -> None:
...
@@ -226,7 +237,7 @@ def test_ip_trunk_deletion(client: TestClient) -> None:
@responses.activate
@responses.activate
def
test_ip_trunk_migration
(
client
:
TestClient
)
->
None
:
def
test_ip_trunk_migration
(
client
:
TestClient
,
subscription_object
:
dict
,
migration_object
:
dict
)
->
None
:
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
params
=
{
params
=
{
...
@@ -236,8 +247,8 @@ def test_ip_trunk_migration(client: TestClient) -> None:
...
@@ -236,8 +247,8 @@ def test_ip_trunk_migration(client: TestClient) -> None:
"
tt_number
"
:
"
TT123456789
"
,
"
tt_number
"
:
"
TT123456789
"
,
"
verb
"
:
"
migrate
"
,
"
verb
"
:
"
migrate
"
,
"
config_object
"
:
"
trunk_interface
"
,
"
config_object
"
:
"
trunk_interface
"
,
"
subscription
"
:
_SUBSCRIPTION_OBJECT
,
"
subscription
"
:
subscription_object
,
"
new_side
"
:
_MIGRATION_OBJECT
,
"
new_side
"
:
migration_object
,
}
}
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
with
patch
(
"
lso.playbook.ansible_runner.run
"
,
new
=
test_ansible_runner_run
)
as
_
:
...
...
This diff is collapsed.
Click to expand it.
test/routes/test_router.py
+
14
−
13
View file @
474f4537
...
@@ -3,6 +3,7 @@ from unittest.mock import patch
...
@@ -3,6 +3,7 @@ from unittest.mock import patch
import
jsonschema
import
jsonschema
import
responses
import
responses
from
faker
import
Faker
from
starlette.testclient
import
TestClient
from
starlette.testclient
import
TestClient
from
lso.playbook
import
PlaybookLaunchResponse
from
lso.playbook
import
PlaybookLaunchResponse
...
@@ -10,29 +11,29 @@ from test.routes import TEST_CALLBACK_URL, test_ansible_runner_run
...
@@ -10,29 +11,29 @@ from test.routes import TEST_CALLBACK_URL, test_ansible_runner_run
@responses.activate
@responses.activate
def
test_router_provisioning
(
client
:
TestClient
)
->
None
:
def
test_router_provisioning
(
client
:
TestClient
,
faker
:
Faker
)
->
None
:
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
responses
.
put
(
url
=
TEST_CALLBACK_URL
,
status
=
204
)
params
=
{
params
=
{
"
callback
"
:
TEST_CALLBACK_URL
,
"
callback
"
:
TEST_CALLBACK_URL
,
"
dry_run
"
:
True
,
"
dry_run
"
:
faker
.
pybool
()
,
"
process_id
"
:
"
cb5f6c71-63d7-4857-9124-4fc6e7ef3f41
"
,
"
process_id
"
:
faker
.
uuid4
()
,
"
tt_number
"
:
"
TT123456789
"
,
"
tt_number
"
:
faker
.
pystr
()
,
"
verb
"
:
"
deploy
"
,
"
verb
"
:
"
deploy
"
,
"
subscription
"
:
{
"
subscription
"
:
{
"
router
"
:
{
"
router
"
:
{
"
ts_address
"
:
"
127.0.0.1
"
,
"
ts_address
"
:
faker
.
ipv4
()
,
"
ts_port
"
:
"
1234
"
,
"
ts_port
"
:
str
(
faker
.
pyint
())
,
"
router_fqdn
"
:
"
bogus.fqdn.org
"
,
"
router_fqdn
"
:
"
bogus.fqdn.org
"
,
"
lo_address
"
:
{
"
v4
"
:
"
1.2.3.4
"
,
"
v6
"
:
"
2001:db8::1
"
},
"
lo_address
"
:
{
"
v4
"
:
faker
.
ipv4
(),
"
v6
"
:
faker
.
ipv6
()
},
"
lo_iso_address
"
:
"
1.2.3.4.5.6
"
,
"
lo_iso_address
"
:
"
1.2.3.4.5.6
"
,
"
snmp_location
"
:
"
city,country[1.2,3.4]
"
,
"
snmp_location
"
:
"
city,country[1.2,3.4]
"
,
"
si_ipv4_network
"
:
"
1.2.3.0
/24
"
,
"
si_ipv4_network
"
:
faker
.
ipv4
()
+
"
/24
"
,
"
ias_lt_network
"
:
{
"
v4
"
:
"
1.2.3.0/24
"
,
"
v6
"
:
"
2001:db8::
/64
"
},
"
ias_lt_network
"
:
{
"
v4
"
:
faker
.
ipv4
()
+
"
/24
"
,
"
v6
"
:
faker
.
ipv6
()
+
"
/64
"
},
"
site_country_code
"
:
"
XX
"
,
"
site_country_code
"
:
faker
.
country_code
()
,
"
site_city
"
:
"
NOWHERE
"
,
"
site_city
"
:
faker
.
city
()
,
"
site_latitude
"
:
"
0.000
"
,
"
site_latitude
"
:
float
(
faker
.
latitude
())
,
"
site_longitude
"
:
"
0.000
"
,
"
site_longitude
"
:
float
(
faker
.
longitude
())
,
},
},
"
router_type
"
:
"
router
"
,
"
router_type
"
:
"
router
"
,
"
router_vendor
"
:
"
vendor
"
,
"
router_vendor
"
:
"
vendor
"
,
...
...
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