Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
congwang09 committed Oct 25, 2024
1 parent f526486 commit e45b5e3
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions sdx_controller/test/test_l2vpn_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_delete_connection_with_setup(self):

print(f"Response body: {connection_response.data.decode('utf-8')}")

assert connection_response // 100 == 2
assert connection_response.status_code // 100 == 2

service_id = connection_response.get_json().get("service_id")
print(f"Deleting request_id: {service_id}")
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_getconnection_by_id(self):
# The service_id we've supplied above should not exist.
# TODO: test for existing service_id. See
# https://github.com/atlanticwave-sdx/sdx-controller/issues/34.
assert response // 100 == 4
assert response.status_code // 100 == 4

def test_place_connection_no_topology(self):
"""
Expand All @@ -120,7 +120,7 @@ def test_place_connection_no_topology(self):
# Expect 400 failure because the request is incomplete: the
# bare minimum connection request we sent does not have
# ingress port data, etc., for example.
assert response // 100 == 4
assert response.status_code // 100 == 4

def test_place_connection_v2_no_topology(self):
"""
Expand All @@ -141,7 +141,7 @@ def test_place_connection_v2_no_topology(self):
# Expect 400 failure because the request is incomplete: the
# bare minimum connection request we sent does not have
# ingress port data, etc., for example.
assert response // 100 == 4
assert response.status_code // 100 == 4

def __test_with_one_topology(self, topology_file):
"""
Expand All @@ -163,7 +163,7 @@ def __test_with_one_topology(self, topology_file):

# Expect 400 failure, because TEManager do not have enough
# topology data.
assert response // 100 == 4
assert response.status_code // 100 == 4

def test_place_connection_with_amlight(self):
"""
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_place_connection_no_id(self):

# Expect a 400 response because the required ID field is
# missing from the request.
assert response // 100 == 4
assert response.status_code // 100 == 4

# JSON response should have a body like:
#
Expand All @@ -218,7 +218,6 @@ def test_place_connection_no_id(self):
# }

response = response.get_json()
assert response["status"] // 100 == 4
self.assertIn("is not valid under any of the given schemas", response["detail"])

def test_place_connection_with_three_topologies(self):
Expand All @@ -242,7 +241,7 @@ def test_place_connection_with_three_topologies(self):

# Expect 200 success because TEManager now should be properly
# set up with all the expected topology data.
assert response // 100 == 2
assert response.status_code // 100 == 2

def test_place_connection_with_three_topologies_added_in_sequence(self):
"""
Expand Down Expand Up @@ -276,11 +275,11 @@ def test_place_connection_with_three_topologies_added_in_sequence(self):
if idx in [0, 1]:
# Expect 400 failure because TEManager do not have all
# the topologies yet.
assert response // 100 == 2
assert response.status_code // 100 == 2
if idx == 200:
# Expect 200 success now that TEManager should be set
# up with all the expected topology data.
assert response // 100 == 2
assert response.status_code // 100 == 2

def test_place_connection_v2_with_three_topologies_400_response(self):
"""
Expand Down Expand Up @@ -313,7 +312,7 @@ def test_place_connection_v2_with_three_topologies_400_response(self):

# Expect a 400 response because PCE would not be able to find
# a solution for the connection request.
assert response // 100 == 4
assert response.status_code // 100 == 4
self.assertEqual(
response.get_json().get("status"),
"Failure",
Expand Down Expand Up @@ -366,7 +365,7 @@ def test_place_connection_v2_with_three_topologies_201_response(self):

# Expect a 200 response because PCE should be able to find a
# solution for the connection request.
assert response // 100 == 2
assert response.status_code // 100 == 2
self.assertEqual(
response.get_json().get("status"),
"OK",
Expand Down Expand Up @@ -414,7 +413,7 @@ def test_place_connection_v2_with_any_vlan_in_request(self):
print(f"POST response body is : {response.data.decode('utf-8')}")
print(f"POST Response JSON is : {response.get_json()}")

assert response // 100 == 2
assert response.status_code // 100 == 2

service_id = response.get_json().get("service_id")

Expand All @@ -426,7 +425,7 @@ def test_place_connection_v2_with_any_vlan_in_request(self):
print(f"GET response body is : {response.data.decode('utf-8')}")
print(f"GET response JSON is : {response.get_json()}")

assert response // 100 == 2
assert response.status_code // 100 == 2

# Expect a response like this:
#
Expand Down Expand Up @@ -513,7 +512,7 @@ def test_z100_getconnection_by_id_expect_404(self):

print(f"Response body is : {response.data.decode('utf-8')}")

assert response // 100 == 4
assert response.status_code // 100 == 4

def test_z100_getconnection_by_id_expect_200(self):
"""
Expand All @@ -533,7 +532,7 @@ def test_z100_getconnection_by_id_expect_200(self):

print(f"Response body: {post_response.data.decode('utf-8')}")

assert post_response // 100 == 2
assert post_response.status_code // 100 == 2

service_id = post_response.get_json().get("service_id")
print(f"Got service_id: {service_id}")
Expand All @@ -546,7 +545,7 @@ def test_z100_getconnection_by_id_expect_200(self):

print(f"Response body: {get_response.data.decode('utf-8')}")

assert get_response // 100 == 2
assert get_response.status_code // 100 == 2

@patch("sdx_controller.utils.db_utils.DbUtils.get_all_entries_in_collection")
def test_z105_getconnections_fail(self, mock_get_all_entries):
Expand All @@ -556,7 +555,7 @@ def test_z105_getconnections_fail(self, mock_get_all_entries):
f"{BASE_PATH}/l2vpn/1.0",
method="GET",
)
self.assertStatus(response, 404)
assert response.status_code // 100 == 4

def test_z105_getconnections_success(self):
"""Test case for getconnections."""
Expand All @@ -566,7 +565,7 @@ def test_z105_getconnections_success(self):
)

print(f"Response body is : {response.data.decode('utf-8')}")
assert response // 100 == 2
assert response.status_code // 100 == 2

assert len(response.get_json()) != 0

Expand Down

0 comments on commit e45b5e3

Please sign in to comment.