Skip to content

Commit

Permalink
change names of interfaces to not disturb other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Josephine.Rutten committed Dec 20, 2024
1 parent fce3f20 commit c8c0f2b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/cnaas_nms/api/tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def requirements(self, postgresql, settings_directory):

def cleandb(self):
with sqla_session() as session: # type: ignore
for interface_name in ["testinterface1", "testinterface2"]:
for interface_name in ["custom_testinterface1", "custom_testinterface2"]:
interface = session.query(Interface).filter(Interface.name == interface_name).one_or_none()
if interface:
session.delete(interface)
Expand Down Expand Up @@ -69,15 +69,15 @@ def add_device(self):
def add_interfaces(self, device_id):
with sqla_session() as session: # type: ignore
interface = Interface(
name="testinterface1",
name="custom_testinterface1",
configtype=InterfaceConfigType.ACCESS_AUTO,
data={
"patch_position": "3E-H12",
},
device_id=device_id,
)
interface2 = Interface(
name="testinterface2",
name="custom_testinterface2",
configtype=InterfaceConfigType.ACCESS_AUTO,
data={},
device_id=device_id,
Expand All @@ -91,18 +91,19 @@ def test_get_interface(self):
self.assertEqual(result.status_code, 200)
json_data = json.loads(result.data.decode())
self.assertEqual(
["testinterface1", "testinterface2"], [interface["name"] for interface in json_data["data"]["interfaces"]]
["custom_testinterface1", "custom_testinterface2"],
[interface["name"] for interface in json_data["data"]["interfaces"]],
)

def test_update_interface_not_unique(self):
def test_update_interface_invalid_patch_position_not_unique(self):
modify_data = {
"interfaces": {
"testinterface1": {
"custom_testinterface1": {
"data": {
"description": "new description",
}
},
"testinterface2": {
"custom_testinterface2": {
"data": {
"patch_position": "3E-H12",
}
Expand All @@ -117,12 +118,12 @@ def test_update_interface_not_unique(self):
def test_update_interface(self):
modify_data = {
"interfaces": {
"testinterface1": {
"custom_testinterface1": {
"data": {
"description": "test",
}
},
"testinterface2": {
"custom_testinterface2": {
"data": {
"description": "test",
"patch_position": "XW.H4.23",
Expand All @@ -133,7 +134,7 @@ def test_update_interface(self):
result = self.client.put(f"/api/v1.0/device/{self.device_hostname}/interfaces", json=modify_data)
json_data = json.loads(result.data.decode())
self.assertEqual(result.status_code, 200)
self.assertEqual(["testinterface1", "testinterface2"], list(json_data["data"]["updated"].keys()))
self.assertEqual(["custom_testinterface1", "custom_testinterface2"], list(json_data["data"]["updated"].keys()))


if __name__ == "__main__":
Expand Down

0 comments on commit c8c0f2b

Please sign in to comment.