Skip to content

Commit

Permalink
unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
YufengXin committed May 7, 2024
1 parent 9fb8daf commit 0cc85f4
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 24 deletions.
1 change: 0 additions & 1 deletion test/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# coding: utf-8
2 changes: 1 addition & 1 deletion test/test_api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
31 changes: 28 additions & 3 deletions test/test_connection_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down Expand Up @@ -44,10 +44,35 @@ def test_getconnection_by_id(self):

def test_place_connection(self):
"""Test case for place_connection
Place an connection request from the SDX-Controller # noqa: E501
"""
pass
p1 = sdx_lc_client.Port(
id="n1:p1", name="p1", short_name="eth1", node="n1", status="UP"
)
p2 = sdx_lc_client.Port(
id="n2:p1", name="p2", short_name="eth2", node="n2", status="UP"
)
timestmp = "2021-06-24T00:05:23+04:00"
connection_body = sdx_lc_client.Connection(
id="test1",
name="test1",
ingress_port=p1,
egress_port=p2,
start_time=timestmp,
end_time=timestmp,
)
try:
# create a connection
# logger.warning(connection_body)
api_response = self.api.place_connection(connection_body)
print(api_response)
# logger.warning(api_response)
except ApiException as e:
print(e)
# logger.warning("Exception when calling ConnectionApi->place_experiment: %s\n" % e)
return False

return True


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion test/test_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_link_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
6 changes: 3 additions & 3 deletions test/test_link_measurement_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand All @@ -15,9 +15,9 @@
import unittest

import sdx_lc_client
from sdx_lc_client.models.link_measurement_period import (
from sdx_lc_client.models.link_measurement_period import ( # noqa: E501
LinkMeasurementPeriod,
) # noqa: E501
)
from sdx_lc_client.rest import ApiException


Expand Down
2 changes: 1 addition & 1 deletion test/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
29 changes: 26 additions & 3 deletions test/test_node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand All @@ -30,10 +30,33 @@ def tearDown(self):

def test_add_node(self):
"""Test case for add_node
add a new node to the topology # noqa: E501
"""
pass
p1 = sdx_lc_client.Port(
id="n1:p1", name="p1", short_name="eth1", node="n1", status="UP"
)
p2 = sdx_lc_client.Port(
id="n2:p1", name="p2", short_name="eth2", node="n2", status="UP"
)
ps = []
ps.append(p1)
# ps.append(p2)
lt = sdx_lc_client.Location(
address="miami", latitude=-28.51107891831147, longitude=-79.57947854792273
)
node_body = sdx_lc_client.Node(id="test1", name="test1", location=lt, ports=ps)
try:
# create a connection
# logger.warning(connection_body)
api_response = self.api.add_node(node_body)
print(api_response)
# logger.warning(api_response)
except ApiException as e:
print(e)
# logger.warning("Exception when calling ConnectionApi->place_experiment: %s\n" % e)
return False

return True

def test_delete_node(self):
"""Test case for delete_node
Expand Down
2 changes: 1 addition & 1 deletion test/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
44 changes: 41 additions & 3 deletions test/test_topology_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand All @@ -30,10 +30,48 @@ def tearDown(self):

def test_add_topology(self):
"""Test case for add_topology
Send a new topology to SDX-LC # noqa: E501
"""
pass
p1 = sdx_lc_client.Port(
id="n1:p1", name="p1", short_name="eth1", node="n1", status="UP"
)
p2 = sdx_lc_client.Port(
id="n2:p1", name="p2", short_name="eth2", node="n2", status="UP"
)
ps = []
ps.append(p1)
ps.append(p2)
lt = sdx_lc_client.Location(address="miami")
node = sdx_lc_client.Node(id="node1", name="node1", location=lt, ports=ps)
ns = []
ns.append(node)

link = sdx_lc_client.Link(id="link1", name="link1", ports=ps)
ls = []
ls.append(link)

timestmp = "2021-06-24T04:56:07+00:00"
topology_body = sdx_lc_client.Topology(
id="topology1",
name="topology1",
nodes=ns,
links=ls,
version=1,
time_stamp=timestmp,
)

try:
# create a connection
# logger.warning(connection_body)
api_response = self.api.add_topology(topology_body)
print(api_response)
# logger.warning(api_response)
except ApiException as e:
print(e)
# logger.warning("Exception when calling ConnectionApi->place_experiment: %s\n" % e)
return False

return True

def test_delete_topology(self):
"""Test case for delete_topology
Expand Down
2 changes: 1 addition & 1 deletion test/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down
2 changes: 1 addition & 1 deletion test/test_user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). # noqa: E501
OpenAPI spec version: 2.0.0
OpenAPI spec version: 1.0.0
Contact: [email protected]
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
Expand Down

0 comments on commit 0cc85f4

Please sign in to comment.