From 9728d81e205a6e3c332eb3af14174afb092d523e Mon Sep 17 00:00:00 2001
From: Robert Latta <robert.latta@geant.org>
Date: Wed, 10 Feb 2021 09:37:24 +0000
Subject: [PATCH] added test for get_circuit_hierachy

---
 test/data/ims_circuit_hierarchy_data.json | 1016 +++++++++++++++++++++
 test/test_ims_data.py                     |   42 +-
 2 files changed, 1057 insertions(+), 1 deletion(-)
 create mode 100644 test/data/ims_circuit_hierarchy_data.json

diff --git a/test/data/ims_circuit_hierarchy_data.json b/test/data/ims_circuit_hierarchy_data.json
new file mode 100644
index 00000000..1027accc
--- /dev/null
+++ b/test/data/ims_circuit_hierarchy_data.json
@@ -0,0 +1,1016 @@
+[
+  {
+    "acquisitiondate": null,
+    "antennafeeders": null,
+    "bicableports": null,
+    "blocked": 0,
+    "cableports": null,
+    "calculatedlength": null,
+    "carriercircuits": [
+      {
+        "carriercircuit": {
+          "acquisitiondate": null,
+          "antennafeeders": null,
+          "bicableports": null,
+          "blocked": 0,
+          "cableports": null,
+          "calculatedlength": null,
+          "carriercircuits": null,
+          "channelreservations": null,
+          "circuitaliases": null,
+          "circuitattachments": null,
+          "circuitcoordinates": null,
+          "circuitcounts": null,
+          "circuitdomains": null,
+          "circuitmanagementsystems": null,
+          "circuitmergingrelatedcircuits": null,
+          "circuitprotectionprotections": null,
+          "circuitprotectionworkers": null,
+          "circuitrequestor": "",
+          "circuittypeid": 0,
+          "coscircuits": null,
+          "createdate": "2020-02-19T20:20:07",
+          "createuser": null,
+          "createuserid": 8338,
+          "csc": null,
+          "cscid": null,
+          "customer": null,
+          "customerid": 57773,
+          "ddfodfports": null,
+          "ddfodfpositionfromto": null,
+          "ddfodfpositions": null,
+          "deliverdate": "2020-02-19T20:20:07",
+          "designref": "",
+          "dsls": null,
+          "errors": null,
+          "extrainfo": "",
+          "extrainfoimportant": 0,
+          "fitstatus": "",
+          "floorplanlines": null,
+          "frameatms": null,
+          "framessizerequired": null,
+          "framing": "",
+          "geocircuitspiped": null,
+          "geodataisineditmode": null,
+          "geoworkersandprotections": null,
+          "haserrors": false,
+          "id": 660461,
+          "internalporta": null,
+          "internalportaid": null,
+          "internalportb": null,
+          "internalportbid": null,
+          "internalports": null,
+          "inventorystatusid": 3,
+          "ipranges": null,
+          "isprotected": 0,
+          "linecoding": "",
+          "linkcosts": null,
+          "lossmeasured": null,
+          "measuredlength": null,
+          "mergecircuitmergingrelatedcircuits": null,
+          "migrationdate": "2020-10-07T17:44:44",
+          "mspprotections": null,
+          "mspworkers": null,
+          "name": "V-LAN_200_MX1.LON.UK_XE-0/0/1_",
+          "nodea": null,
+          "nodeaid": 129756,
+          "nodeb": null,
+          "nodebid": 129079,
+          "oldcircuits": null,
+          "oldname": "",
+          "olocircuits": null,
+          "order": null,
+          "orderid": null,
+          "outofservicedate": null,
+          "plmidate": null,
+          "ploosdate": null,
+          "porta": null,
+          "portaid": 6430303,
+          "portb": null,
+          "portbid": 6419305,
+          "portchannelrelations": null,
+          "portreservations": null,
+          "ports": null,
+          "product": null,
+          "productid": 3677,
+          "projectnumber": "",
+          "projectstatus": null,
+          "protectiontype": "",
+          "protectiontypec": "",
+          "prottypea": "",
+          "prottypez": "",
+          "pwcircuits": null,
+          "pwmaincircuits": null,
+          "reconcilecircuits": null,
+          "relatedorders": null,
+          "ringsections": null,
+          "rowversion": "2021-01-12T09:03:56",
+          "rtdcontract": "",
+          "rtdmaincalc": "",
+          "rtdmainmeasured": "",
+          "rtdsparecalc": "",
+          "rtdsparemeasured": "",
+          "sellingunit": "",
+          "sequencenumber": "",
+          "servicecircuits": null,
+          "serviceparts": "JUNIPER",
+          "sitea": null,
+          "siteaid": 445244,
+          "siteb": null,
+          "sitebid": 445244,
+          "sla": null,
+          "slacks": null,
+          "slaid": null,
+          "speed": null,
+          "speedid": 3045,
+          "spofcircuits": null,
+          "spofresultcircuits": null,
+          "spofresultcomparecircuits": null,
+          "spofresultprotectioncircuits": null,
+          "spofresultprotectioncircuits2": null,
+          "spofresultsubprotectioncircuits": null,
+          "spofresultsubprotectioncircuits2": null,
+          "spofresultsubworkercircuits": null,
+          "spofresultsubworkercircuits2": null,
+          "spofresultworkercircuits": null,
+          "spofresultworkercircuits2": null,
+          "stdornonstd": 0,
+          "structuretype": "",
+          "subcircuits": null,
+          "tested": 0,
+          "vendor": "JUNIPER",
+          "vlanid": null,
+          "vminternalportrelatelist": null,
+          "vmportrelatelist": null,
+          "wtoptunnelprotections": null,
+          "wtoptunnelworkers": null
+        },
+        "carriercircuitid": 660461,
+        "channelkind": "ETHS",
+        "circuitrelationchannelalias": {
+          "channelalias": null,
+          "channelaliasid": null,
+          "errors": null,
+          "haserrors": false,
+          "id": 2491116,
+          "rowversion": "2020-12-10T19:52:28"
+        },
+        "comments": "",
+        "directionid": 0,
+        "errors": null,
+        "haserrors": false,
+        "id": 2491116,
+        "order": null,
+        "orderid": null,
+        "projectnumber": "",
+        "projectstatus": 1,
+        "rowversion": "2020-12-10T19:52:28",
+        "sequencenumber": 1,
+        "subcircuit": null,
+        "subcircuitid": 661591,
+        "timeslotfrom": 0,
+        "timeslotto": 0
+      }
+    ],
+    "channelreservations": null,
+    "circuitaliases": null,
+    "circuitattachments": null,
+    "circuitcoordinates": null,
+    "circuitcounts": null,
+    "circuitdomains": null,
+    "circuitmanagementsystems": null,
+    "circuitmergingrelatedcircuits": null,
+    "circuitprotectionprotections": null,
+    "circuitprotectionworkers": null,
+    "circuitrequestor": "",
+    "circuittypeid": 0,
+    "coscircuits": null,
+    "createdate": "2020-02-19T20:48:42",
+    "createuser": null,
+    "createuserid": 8338,
+    "csc": null,
+    "cscid": null,
+    "customer": {
+      "accountemail": "",
+      "accountmanager": "",
+      "address": "",
+      "channelreservations": null,
+      "circuits": null,
+      "code": "",
+      "contractcustomerrelations": null,
+      "country": null,
+      "countryid": null,
+      "customerrelatedcontacts": null,
+      "customerrelatedcontracts": null,
+      "customertype": null,
+      "customertypeid": 7,
+      "errors": null,
+      "esimprofiles": null,
+      "esims": null,
+      "faxnumber": "",
+      "fullname": "ORIENTPLUS",
+      "haserrors": false,
+      "id": 57773,
+      "innumbers": null,
+      "ipranges": null,
+      "managementsystems": null,
+      "name": "ORIENTPLUS",
+      "nodes": null,
+      "number": null,
+      "numbermanagementlist": null,
+      "olocircuits": null,
+      "orders": null,
+      "parentcustomer": null,
+      "parentcustomerid": null,
+      "phonenumber": "",
+      "portreservations": null,
+      "pwcodeblue": 0,
+      "pwemailsetups": null,
+      "pwextrainfo": "",
+      "pwinformatrisk": 1,
+      "pwinformdown": 1,
+      "pwinformedlist": null,
+      "pwinformimpact": 1,
+      "pwinformnoimpact": 1,
+      "pwinformprotectionswitch": 1,
+      "pwlanguage": "",
+      "racks": null,
+      "rowversion": "2020-02-14T20:56:59",
+      "servicecenter": 0,
+      "servicecentername": "",
+      "sites": null,
+      "sla": null,
+      "slaid": null,
+      "speeds": null,
+      "subcustomers": null,
+      "telephonenumberranges": null,
+      "telephonenumbers": null,
+      "website": ""
+    },
+    "customerid": 57773,
+    "ddfodfports": null,
+    "ddfodfpositionfromto": null,
+    "ddfodfpositions": null,
+    "deliverdate": "2020-02-20T20:33:43",
+    "designref": "",
+    "dsls": null,
+    "errors": null,
+    "extrainfo": "",
+    "extrainfoimportant": 0,
+    "fitstatus": "",
+    "floorplanlines": null,
+    "frameatms": null,
+    "framessizerequired": null,
+    "framing": "",
+    "geocircuitspiped": null,
+    "geodataisineditmode": null,
+    "geoworkersandprotections": null,
+    "haserrors": false,
+    "id": 661591,
+    "internalporta": null,
+    "internalportaid": null,
+    "internalportb": null,
+    "internalportbid": null,
+    "internalports": null,
+    "inventorystatusid": 3,
+    "ipranges": null,
+    "isprotected": 0,
+    "linecoding": "",
+    "linkcosts": null,
+    "lossmeasured": null,
+    "measuredlength": null,
+    "mergecircuitmergingrelatedcircuits": null,
+    "migrationdate": "2020-12-10T19:52:28",
+    "mspprotections": null,
+    "mspworkers": null,
+    "name": "UK_ORIENT",
+    "nodea": null,
+    "nodeaid": 129756,
+    "nodeb": null,
+    "nodebid": 129079,
+    "oldcircuits": null,
+    "oldname": "",
+    "olocircuits": null,
+    "order": null,
+    "orderid": null,
+    "outofservicedate": null,
+    "plmidate": null,
+    "ploosdate": null,
+    "porta": null,
+    "portaid": 6430303,
+    "portb": null,
+    "portbid": 6419305,
+    "portchannelrelations": null,
+    "portreservations": null,
+    "ports": null,
+    "product": {
+      "aliasproduct": "",
+      "circuits": [],
+      "contid": "",
+      "createsubcircuits": "",
+      "description": "IP PEERING - R&E",
+      "diameter": null,
+      "domain": null,
+      "domainid": null,
+      "errors": null,
+      "fiberlosspermeter": null,
+      "groupid": "",
+      "haserrors": false,
+      "id": 3819,
+      "materialtypes": null,
+      "name": "IP PEERING - R&E",
+      "productlines": "",
+      "report": 0,
+      "rowversion": "2020-07-07T10:58:36",
+      "speed": null,
+      "speedid": null,
+      "speeds": null,
+      "thickness": null
+    },
+    "productid": 3819,
+    "projectnumber": "",
+    "projectstatus": null,
+    "protectiontype": "",
+    "protectiontypec": "",
+    "prottypea": "",
+    "prottypez": "",
+    "pwcircuits": null,
+    "pwmaincircuits": null,
+    "reconcilecircuits": null,
+    "relatedorders": null,
+    "ringsections": null,
+    "rowversion": "2021-01-12T09:31:41",
+    "rtdcontract": "",
+    "rtdmaincalc": "",
+    "rtdmainmeasured": "",
+    "rtdsparecalc": "",
+    "rtdsparemeasured": "",
+    "sellingunit": "",
+    "sequencenumber": "",
+    "servicecircuits": null,
+    "serviceparts": "JUNIPER",
+    "sitea": null,
+    "siteaid": 445244,
+    "siteb": null,
+    "sitebid": 445244,
+    "sla": null,
+    "slacks": null,
+    "slaid": null,
+    "speed": {
+      "aendmandatory": 1,
+      "carrierchannelaliases": null,
+      "carrierlayerrules": null,
+      "channelview": "NORMAL",
+      "circuitnametemplate": "",
+      "circuits": [],
+      "circuittypeoption": 0,
+      "defaultcustomer": null,
+      "defaultcustomerid": 57744,
+      "defaultproduct": null,
+      "defaultproductid": 3677,
+      "defaultserviceparts": "",
+      "defaultvendor": "",
+      "drawsubcircuit": 0,
+      "e2echeck": 0,
+      "errors": null,
+      "extrainfo": "",
+      "graphicalx": null,
+      "graphicaly": null,
+      "haserrors": false,
+      "id": 3044,
+      "isgeo": 0,
+      "kbits": null,
+      "layouttype": "NORMAL",
+      "maxgraphicallayerdepth": 2,
+      "multipoint": 0,
+      "name": "ETHS",
+      "oloproducts": null,
+      "olospeedallowed": "",
+      "optical": 0,
+      "products": null,
+      "rowversion": "2020-02-07T14:50:26",
+      "showcircuitaddnewmenu": 1,
+      "showsubcircuitmenu": 1,
+      "showvlanid": 0,
+      "speedcolor": null,
+      "speedtype": "S",
+      "subchannelaliases": null,
+      "subchannelfrom": 0,
+      "subchannelto": 4095,
+      "subchanneltype": "",
+      "subcircuitlayerrules": null,
+      "test": 0,
+      "usesubcapacity": 0,
+      "wizardusable": 0,
+      "zendmandatory": 1
+    },
+    "speedid": 3044,
+    "spofcircuits": null,
+    "spofresultcircuits": null,
+    "spofresultcomparecircuits": null,
+    "spofresultprotectioncircuits": null,
+    "spofresultprotectioncircuits2": null,
+    "spofresultsubprotectioncircuits": null,
+    "spofresultsubprotectioncircuits2": null,
+    "spofresultsubworkercircuits": null,
+    "spofresultsubworkercircuits2": null,
+    "spofresultworkercircuits": null,
+    "spofresultworkercircuits2": null,
+    "stdornonstd": 0,
+    "structuretype": "",
+    "subcircuits": [],
+    "tested": 0,
+    "vendor": "JUNIPER",
+    "vlanid": null,
+    "vminternalportrelatelist": null,
+    "vmportrelatelist": null,
+    "wtoptunnelprotections": null,
+    "wtoptunnelworkers": null
+  },
+  {
+    "acquisitiondate": null,
+    "antennafeeders": null,
+    "bicableports": null,
+    "blocked": 0,
+    "cableports": null,
+    "calculatedlength": null,
+    "carriercircuits": [
+      {
+        "carriercircuit": {
+          "acquisitiondate": null,
+          "antennafeeders": null,
+          "bicableports": null,
+          "blocked": 0,
+          "cableports": null,
+          "calculatedlength": null,
+          "carriercircuits": null,
+          "channelreservations": null,
+          "circuitaliases": null,
+          "circuitattachments": null,
+          "circuitcoordinates": null,
+          "circuitcounts": null,
+          "circuitdomains": null,
+          "circuitmanagementsystems": null,
+          "circuitmergingrelatedcircuits": null,
+          "circuitprotectionprotections": null,
+          "circuitprotectionworkers": null,
+          "circuitrequestor": "",
+          "circuittypeid": 0,
+          "coscircuits": null,
+          "createdate": "2020-03-10T15:38:46",
+          "createuser": null,
+          "createuserid": 6727,
+          "csc": null,
+          "cscid": null,
+          "customer": null,
+          "customerid": 57773,
+          "ddfodfports": null,
+          "ddfodfpositionfromto": null,
+          "ddfodfpositions": null,
+          "deliverdate": "2020-08-31T11:16:48",
+          "designref": "",
+          "dsls": null,
+          "errors": null,
+          "extrainfo": "",
+          "extrainfoimportant": 0,
+          "fitstatus": "",
+          "floorplanlines": null,
+          "frameatms": null,
+          "framessizerequired": null,
+          "framing": "",
+          "geocircuitspiped": null,
+          "geodataisineditmode": null,
+          "geoworkersandprotections": null,
+          "haserrors": false,
+          "id": 668866,
+          "internalporta": null,
+          "internalportaid": null,
+          "internalportb": null,
+          "internalportbid": null,
+          "internalports": null,
+          "inventorystatusid": 3,
+          "ipranges": null,
+          "isprotected": 0,
+          "linecoding": "",
+          "linkcosts": null,
+          "lossmeasured": null,
+          "measuredlength": null,
+          "mergecircuitmergingrelatedcircuits": null,
+          "migrationdate": "2020-12-10T19:50:36",
+          "mspprotections": null,
+          "mspworkers": null,
+          "name": "LON-BEIJING-LEASEDSPAN",
+          "nodea": null,
+          "nodeaid": 129079,
+          "nodeb": null,
+          "nodebid": 129756,
+          "oldcircuits": null,
+          "oldname": "",
+          "olocircuits": null,
+          "order": null,
+          "orderid": 70168,
+          "outofservicedate": null,
+          "plmidate": null,
+          "ploosdate": null,
+          "porta": null,
+          "portaid": 6419305,
+          "portb": null,
+          "portbid": 6430303,
+          "portchannelrelations": null,
+          "portreservations": null,
+          "ports": null,
+          "product": null,
+          "productid": 3677,
+          "projectnumber": "",
+          "projectstatus": null,
+          "protectiontype": "",
+          "protectiontypec": "",
+          "prottypea": "",
+          "prottypez": "",
+          "pwcircuits": null,
+          "pwmaincircuits": null,
+          "reconcilecircuits": null,
+          "relatedorders": null,
+          "ringsections": null,
+          "rowversion": "2021-01-12T08:58:53",
+          "rtdcontract": "",
+          "rtdmaincalc": "",
+          "rtdmainmeasured": "",
+          "rtdsparecalc": "",
+          "rtdsparemeasured": "",
+          "sellingunit": "",
+          "sequencenumber": "",
+          "servicecircuits": null,
+          "serviceparts": "UNKNOWN",
+          "sitea": null,
+          "siteaid": 445244,
+          "siteb": null,
+          "sitebid": 445060,
+          "sla": null,
+          "slacks": null,
+          "slaid": null,
+          "speed": null,
+          "speedid": 3064,
+          "spofcircuits": null,
+          "spofresultcircuits": null,
+          "spofresultcomparecircuits": null,
+          "spofresultprotectioncircuits": null,
+          "spofresultprotectioncircuits2": null,
+          "spofresultsubprotectioncircuits": null,
+          "spofresultsubprotectioncircuits2": null,
+          "spofresultsubworkercircuits": null,
+          "spofresultsubworkercircuits2": null,
+          "spofresultworkercircuits": null,
+          "spofresultworkercircuits2": null,
+          "stdornonstd": 0,
+          "structuretype": "",
+          "subcircuits": null,
+          "tested": 0,
+          "vendor": "CHINA UNICOM",
+          "vlanid": null,
+          "vminternalportrelatelist": null,
+          "vmportrelatelist": null,
+          "wtoptunnelprotections": null,
+          "wtoptunnelworkers": null
+        },
+        "carriercircuitid": 668866,
+        "channelkind": "VLAN",
+        "circuitrelationchannelalias": {
+          "channelalias": null,
+          "channelaliasid": null,
+          "errors": null,
+          "haserrors": false,
+          "id": 2493336,
+          "rowversion": "2020-10-12T09:30:36"
+        },
+        "comments": "",
+        "directionid": 0,
+        "errors": null,
+        "haserrors": false,
+        "id": 2493336,
+        "order": null,
+        "orderid": null,
+        "projectnumber": "",
+        "projectstatus": 1,
+        "rowversion": "2020-10-12T09:30:36",
+        "sequencenumber": 1,
+        "subcircuit": null,
+        "subcircuitid": 660461,
+        "timeslotfrom": 200,
+        "timeslotto": 200
+      }
+    ],
+    "channelreservations": null,
+    "circuitaliases": null,
+    "circuitattachments": null,
+    "circuitcoordinates": null,
+    "circuitcounts": null,
+    "circuitdomains": null,
+    "circuitmanagementsystems": null,
+    "circuitmergingrelatedcircuits": null,
+    "circuitprotectionprotections": null,
+    "circuitprotectionworkers": null,
+    "circuitrequestor": "",
+    "circuittypeid": 0,
+    "coscircuits": null,
+    "createdate": "2020-02-19T20:20:07",
+    "createuser": null,
+    "createuserid": 8338,
+    "csc": null,
+    "cscid": null,
+    "customer": {
+      "accountemail": "",
+      "accountmanager": "",
+      "address": "",
+      "channelreservations": null,
+      "circuits": null,
+      "code": "",
+      "contractcustomerrelations": null,
+      "country": null,
+      "countryid": null,
+      "customerrelatedcontacts": null,
+      "customerrelatedcontracts": null,
+      "customertype": null,
+      "customertypeid": 7,
+      "errors": null,
+      "esimprofiles": null,
+      "esims": null,
+      "faxnumber": "",
+      "fullname": "ORIENTPLUS",
+      "haserrors": false,
+      "id": 57773,
+      "innumbers": null,
+      "ipranges": null,
+      "managementsystems": null,
+      "name": "ORIENTPLUS",
+      "nodes": null,
+      "number": null,
+      "numbermanagementlist": null,
+      "olocircuits": null,
+      "orders": null,
+      "parentcustomer": null,
+      "parentcustomerid": null,
+      "phonenumber": "",
+      "portreservations": null,
+      "pwcodeblue": 0,
+      "pwemailsetups": null,
+      "pwextrainfo": "",
+      "pwinformatrisk": 1,
+      "pwinformdown": 1,
+      "pwinformedlist": null,
+      "pwinformimpact": 1,
+      "pwinformnoimpact": 1,
+      "pwinformprotectionswitch": 1,
+      "pwlanguage": "",
+      "racks": null,
+      "rowversion": "2020-02-14T20:56:59",
+      "servicecenter": 0,
+      "servicecentername": "",
+      "sites": null,
+      "sla": null,
+      "slaid": null,
+      "speeds": null,
+      "subcustomers": null,
+      "telephonenumberranges": null,
+      "telephonenumbers": null,
+      "website": ""
+    },
+    "customerid": 57773,
+    "ddfodfports": null,
+    "ddfodfpositionfromto": null,
+    "ddfodfpositions": null,
+    "deliverdate": "2020-02-19T20:20:07",
+    "designref": "",
+    "dsls": null,
+    "errors": null,
+    "extrainfo": "",
+    "extrainfoimportant": 0,
+    "fitstatus": "",
+    "floorplanlines": null,
+    "frameatms": null,
+    "framessizerequired": null,
+    "framing": "",
+    "geocircuitspiped": null,
+    "geodataisineditmode": null,
+    "geoworkersandprotections": null,
+    "haserrors": false,
+    "id": 660461,
+    "internalporta": null,
+    "internalportaid": null,
+    "internalportb": null,
+    "internalportbid": null,
+    "internalports": null,
+    "inventorystatusid": 3,
+    "ipranges": null,
+    "isprotected": 0,
+    "linecoding": "",
+    "linkcosts": null,
+    "lossmeasured": null,
+    "measuredlength": null,
+    "mergecircuitmergingrelatedcircuits": null,
+    "migrationdate": "2020-10-07T17:44:44",
+    "mspprotections": null,
+    "mspworkers": null,
+    "name": "V-LAN_200_MX1.LON.UK_XE-0/0/1_",
+    "nodea": null,
+    "nodeaid": 129756,
+    "nodeb": null,
+    "nodebid": 129079,
+    "oldcircuits": null,
+    "oldname": "",
+    "olocircuits": null,
+    "order": null,
+    "orderid": null,
+    "outofservicedate": null,
+    "plmidate": null,
+    "ploosdate": null,
+    "porta": null,
+    "portaid": 6430303,
+    "portb": null,
+    "portbid": 6419305,
+    "portchannelrelations": null,
+    "portreservations": null,
+    "ports": null,
+    "product": {
+      "aliasproduct": "",
+      "circuits": [],
+      "contid": "",
+      "createsubcircuits": "",
+      "description": "ETHERNET",
+      "diameter": null,
+      "domain": null,
+      "domainid": null,
+      "errors": null,
+      "fiberlosspermeter": null,
+      "groupid": "",
+      "haserrors": false,
+      "id": 3677,
+      "materialtypes": null,
+      "name": "ETHERNET",
+      "productlines": "",
+      "report": 0,
+      "rowversion": "2020-04-06T12:28:38",
+      "speed": null,
+      "speedid": null,
+      "speeds": null,
+      "thickness": null
+    },
+    "productid": 3677,
+    "projectnumber": "",
+    "projectstatus": null,
+    "protectiontype": "",
+    "protectiontypec": "",
+    "prottypea": "",
+    "prottypez": "",
+    "pwcircuits": null,
+    "pwmaincircuits": null,
+    "reconcilecircuits": null,
+    "relatedorders": null,
+    "ringsections": null,
+    "rowversion": "2021-01-12T09:03:56",
+    "rtdcontract": "",
+    "rtdmaincalc": "",
+    "rtdmainmeasured": "",
+    "rtdsparecalc": "",
+    "rtdsparemeasured": "",
+    "sellingunit": "",
+    "sequencenumber": "",
+    "servicecircuits": null,
+    "serviceparts": "JUNIPER",
+    "sitea": null,
+    "siteaid": 445244,
+    "siteb": null,
+    "sitebid": 445244,
+    "sla": null,
+    "slacks": null,
+    "slaid": null,
+    "speed": {
+      "aendmandatory": 0,
+      "carrierchannelaliases": null,
+      "carrierlayerrules": null,
+      "channelview": "NORMAL",
+      "circuitnametemplate": "",
+      "circuits": [],
+      "circuittypeoption": 0,
+      "defaultcustomer": null,
+      "defaultcustomerid": 57744,
+      "defaultproduct": null,
+      "defaultproductid": 3677,
+      "defaultserviceparts": "",
+      "defaultvendor": "",
+      "drawsubcircuit": 0,
+      "e2echeck": 0,
+      "errors": null,
+      "extrainfo": "",
+      "graphicalx": null,
+      "graphicaly": null,
+      "haserrors": false,
+      "id": 3045,
+      "isgeo": 0,
+      "kbits": null,
+      "layouttype": "NORMAL",
+      "maxgraphicallayerdepth": 2,
+      "multipoint": 0,
+      "name": "V-LAN",
+      "oloproducts": null,
+      "olospeedallowed": "",
+      "optical": 0,
+      "products": null,
+      "rowversion": "2020-02-07T14:51:29",
+      "showcircuitaddnewmenu": 1,
+      "showsubcircuitmenu": 1,
+      "showvlanid": 0,
+      "speedcolor": null,
+      "speedtype": "VLAN",
+      "subchannelaliases": null,
+      "subchannelfrom": 0,
+      "subchannelto": 4095,
+      "subchanneltype": "",
+      "subcircuitlayerrules": null,
+      "test": 0,
+      "usesubcapacity": 0,
+      "wizardusable": 0,
+      "zendmandatory": 0
+    },
+    "speedid": 3045,
+    "spofcircuits": null,
+    "spofresultcircuits": null,
+    "spofresultcomparecircuits": null,
+    "spofresultprotectioncircuits": null,
+    "spofresultprotectioncircuits2": null,
+    "spofresultsubprotectioncircuits": null,
+    "spofresultsubprotectioncircuits2": null,
+    "spofresultsubworkercircuits": null,
+    "spofresultsubworkercircuits2": null,
+    "spofresultworkercircuits": null,
+    "spofresultworkercircuits2": null,
+    "stdornonstd": 0,
+    "structuretype": "",
+    "subcircuits": [
+      {
+        "carriercircuit": null,
+        "carriercircuitid": 660461,
+        "channelkind": "ETHS",
+        "circuitrelationchannelalias": null,
+        "comments": "",
+        "directionid": 0,
+        "errors": null,
+        "haserrors": false,
+        "id": 2491116,
+        "order": null,
+        "orderid": null,
+        "projectnumber": "",
+        "projectstatus": 1,
+        "rowversion": "2020-12-10T19:52:28",
+        "sequencenumber": 1,
+        "subcircuit": {
+          "acquisitiondate": null,
+          "antennafeeders": null,
+          "bicableports": null,
+          "blocked": 0,
+          "cableports": null,
+          "calculatedlength": null,
+          "carriercircuits": null,
+          "channelreservations": null,
+          "circuitaliases": null,
+          "circuitattachments": null,
+          "circuitcoordinates": null,
+          "circuitcounts": null,
+          "circuitdomains": null,
+          "circuitmanagementsystems": null,
+          "circuitmergingrelatedcircuits": null,
+          "circuitprotectionprotections": null,
+          "circuitprotectionworkers": null,
+          "circuitrequestor": "",
+          "circuittypeid": 0,
+          "coscircuits": null,
+          "createdate": "2020-02-19T20:48:42",
+          "createuser": null,
+          "createuserid": 8338,
+          "csc": null,
+          "cscid": null,
+          "customer": null,
+          "customerid": 57773,
+          "ddfodfports": null,
+          "ddfodfpositionfromto": null,
+          "ddfodfpositions": null,
+          "deliverdate": "2020-02-20T20:33:43",
+          "designref": "",
+          "dsls": null,
+          "errors": null,
+          "extrainfo": "",
+          "extrainfoimportant": 0,
+          "fitstatus": "",
+          "floorplanlines": null,
+          "frameatms": null,
+          "framessizerequired": null,
+          "framing": "",
+          "geocircuitspiped": null,
+          "geodataisineditmode": null,
+          "geoworkersandprotections": null,
+          "haserrors": false,
+          "id": 661591,
+          "internalporta": null,
+          "internalportaid": null,
+          "internalportb": null,
+          "internalportbid": null,
+          "internalports": null,
+          "inventorystatusid": 3,
+          "ipranges": null,
+          "isprotected": 0,
+          "linecoding": "",
+          "linkcosts": null,
+          "lossmeasured": null,
+          "measuredlength": null,
+          "mergecircuitmergingrelatedcircuits": null,
+          "migrationdate": "2020-12-10T19:52:28",
+          "mspprotections": null,
+          "mspworkers": null,
+          "name": "UK_ORIENT",
+          "nodea": null,
+          "nodeaid": 129756,
+          "nodeb": null,
+          "nodebid": 129079,
+          "oldcircuits": null,
+          "oldname": "",
+          "olocircuits": null,
+          "order": null,
+          "orderid": null,
+          "outofservicedate": null,
+          "plmidate": null,
+          "ploosdate": null,
+          "porta": null,
+          "portaid": 6430303,
+          "portb": null,
+          "portbid": 6419305,
+          "portchannelrelations": null,
+          "portreservations": null,
+          "ports": null,
+          "product": null,
+          "productid": 3819,
+          "projectnumber": "",
+          "projectstatus": null,
+          "protectiontype": "",
+          "protectiontypec": "",
+          "prottypea": "",
+          "prottypez": "",
+          "pwcircuits": null,
+          "pwmaincircuits": null,
+          "reconcilecircuits": null,
+          "relatedorders": null,
+          "ringsections": null,
+          "rowversion": "2021-01-12T09:31:41",
+          "rtdcontract": "",
+          "rtdmaincalc": "",
+          "rtdmainmeasured": "",
+          "rtdsparecalc": "",
+          "rtdsparemeasured": "",
+          "sellingunit": "",
+          "sequencenumber": "",
+          "servicecircuits": null,
+          "serviceparts": "JUNIPER",
+          "sitea": null,
+          "siteaid": 445244,
+          "siteb": null,
+          "sitebid": 445244,
+          "sla": null,
+          "slacks": null,
+          "slaid": null,
+          "speed": null,
+          "speedid": 3044,
+          "spofcircuits": null,
+          "spofresultcircuits": null,
+          "spofresultcomparecircuits": null,
+          "spofresultprotectioncircuits": null,
+          "spofresultprotectioncircuits2": null,
+          "spofresultsubprotectioncircuits": null,
+          "spofresultsubprotectioncircuits2": null,
+          "spofresultsubworkercircuits": null,
+          "spofresultsubworkercircuits2": null,
+          "spofresultworkercircuits": null,
+          "spofresultworkercircuits2": null,
+          "stdornonstd": 0,
+          "structuretype": "",
+          "subcircuits": null,
+          "tested": 0,
+          "vendor": "JUNIPER",
+          "vlanid": null,
+          "vminternalportrelatelist": null,
+          "vmportrelatelist": null,
+          "wtoptunnelprotections": null,
+          "wtoptunnelworkers": null
+        },
+        "subcircuitid": 661591,
+        "timeslotfrom": 0,
+        "timeslotto": 0
+      }
+    ],
+    "tested": 0,
+    "vendor": "JUNIPER",
+    "vlanid": null,
+    "vminternalportrelatelist": null,
+    "vmportrelatelist": null,
+    "wtoptunnelprotections": null,
+    "wtoptunnelworkers": null
+  }
+]
\ No newline at end of file
diff --git a/test/test_ims_data.py b/test/test_ims_data.py
index 522a4cc1..d907593a 100644
--- a/test/test_ims_data.py
+++ b/test/test_ims_data.py
@@ -5,7 +5,47 @@ from inventory_provider.db.ims import InventoryStatus
 from inventory_provider.db.ims_data import lookup_lg_routers, \
     otrs_get_customer_company_rows, \
     otrs_get_customer_users_rows, get_node_locations, IMS_OPSDB_STATUS_MAP, \
-    get_fibre_info, get_port_id_services, get_port_details
+    get_fibre_info, get_port_id_services, get_port_details, \
+    get_circuit_hierarchy
+
+
+def test_get_circuit_hierarchy(mocker):
+
+    ds = inventory_provider.db.ims.IMS(
+        'dummy_base', 'dummy_username', 'dummy_password')
+    with open('test/data/ims_circuit_hierarchy_data.json') as data:
+        se_data = json.load(data)
+
+    mocked_get = mocker.patch.object(
+        inventory_provider.db.ims.IMS,
+        'get_all_entities'
+    )
+    mocked_get.return_value = se_data
+    res = list(get_circuit_hierarchy(ds))
+    assert ds.get_all_entities.call_count == 1
+    predicted = [
+        {
+            'id': 661591,
+            'name': 'UK_ORIENT',
+            'status': 'operational',
+            'product': 'IP PEERING - R&E',
+            'speed': 'ETHS',
+            'project': 'ORIENTPLUS',
+            'sub-circuits': [],
+            'carrier-circuits': [660461]
+        },
+        {
+            'id': 660461,
+            'name': 'V-LAN_200_MX1.LON.UK_XE-0/0/1_',
+            'status': 'operational',
+            'product': 'ETHERNET',
+            'speed': 'V-LAN',
+            'project': 'ORIENTPLUS',
+            'sub-circuits': [661591],
+            'carrier-circuits': [668866]
+        }
+    ]
+    assert res == predicted
 
 
 def test_get_port_details(mocker):
-- 
GitLab