46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from app.simulation.examples.test_mql.topology import load_test_mql_cir_topology
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
TEST_MQL_AME = REPO_ROOT / "AmesimModels" / "test_mql.ame"
|
|
|
|
|
|
class TestMqlCirTopologyTests(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.topology = load_test_mql_cir_topology(TEST_MQL_AME)
|
|
|
|
def test_recovers_direct_component_contacts_omitted_from_line_specs(self) -> None:
|
|
self.assertEqual(len(self.topology.component_contacts), 54)
|
|
contacts = self.topology.contacts_for("pn_general_chamber")
|
|
|
|
self.assertEqual(len(contacts), 2)
|
|
self.assertEqual(
|
|
{
|
|
(
|
|
contact.port_for("pn_general_chamber"),
|
|
*contact.other_endpoint("pn_general_chamber"),
|
|
)
|
|
for contact in contacts
|
|
},
|
|
{
|
|
("port_1", "pn_orifice_19", "port_2"),
|
|
("port_2", "pn_orifice_18", "port_1"),
|
|
},
|
|
)
|
|
|
|
def test_component_contact_lookup_rejects_unrelated_alias(self) -> None:
|
|
contact = self.topology.contacts_for("pn_general_chamber")[0]
|
|
|
|
with self.assertRaises(KeyError):
|
|
contact.other_endpoint("not-an-endpoint")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|