diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 0133b6084d..cb9a0fced5 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -49,7 +49,7 @@ jobs: python -m pip install --upgrade tox-gh-actions - name: Test with tox # Only the tox environment specified in the tox.ini gh-actions is run - run: tox -e test -- --ignore=tests/examples + run: tox -e test -- --ignore=tests/e2e docs: diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 8a5179bfa7..0000000000 --- a/tests/conftest.py +++ /dev/null @@ -1,2 +0,0 @@ -# Define the fixture plugins -pytest_plugins = ["utils.test_utils"] diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py new file mode 100644 index 0000000000..ed9f22608f --- /dev/null +++ b/tests/e2e/conftest.py @@ -0,0 +1,29 @@ +import pytest +import settings + +from ansys.edb.database import Database +from ansys.edb.layout import Cell, CellType +from ansys.edb.session import session + + +@pytest.fixture +def test_session(): + with session(settings.configs.get("RPC_SERVER_ROOT"), 50051): + yield + + +@pytest.fixture +def new_database_path(tmp_path): + return str(tmp_path / "test.aedb") + + +@pytest.fixture +def new_database(test_session, new_database_path): + db = Database.create(new_database_path) + yield db + db.close() + + +@pytest.fixture +def circuit_cell(new_database): + return Cell.create(new_database, CellType.CIRCUIT_CELL, "circuit_cell") diff --git a/tests/examples/test_spiral_inductor.py b/tests/e2e/integration_tests/test_spiral_inductor.py similarity index 95% rename from tests/examples/test_spiral_inductor.py rename to tests/e2e/integration_tests/test_spiral_inductor.py index 060f45afb5..9609c037e7 100644 --- a/tests/examples/test_spiral_inductor.py +++ b/tests/e2e/integration_tests/test_spiral_inductor.py @@ -2,8 +2,10 @@ import platform import tempfile +import settings + from ansys.edb.database import Database -from ansys.edb.definition import MaterialDef, MaterialProperty +from ansys.edb.definition import MaterialDef from ansys.edb.geometry import PolygonData from ansys.edb.hierarchy import ViaGroup from ansys.edb.layer import LayerCollection, LayerCollectionMode, LayerType, StackupLayer, ViaLayer @@ -19,7 +21,6 @@ ) import ansys.edb.simulation_setup.skin_depth_mesh_operation from ansys.edb.terminal import PointTerminal -import settings # Wrapper class over Database @@ -289,10 +290,10 @@ def create_materials(self): self.create_material( name, { - MaterialProperty.CONDUCTIVITY: properties[0], - MaterialProperty.PERMITTIVITY: properties[1], - MaterialProperty.PERMEABILITY: properties[2], - MaterialProperty.DIELECTRIC_LOSS_TANGENT: properties[3], + MaterialDef.MaterialProperty.CONDUCTIVITY: properties[0], + MaterialDef.MaterialProperty.PERMITTIVITY: properties[1], + MaterialDef.MaterialProperty.PERMEABILITY: properties[2], + MaterialDef.MaterialProperty.DIELECTRIC_LOSS_TANGENT: properties[3], }, ) @@ -353,10 +354,10 @@ def create_coil(self): self.create_material( "Coil_Mat", { - MaterialProperty.CONDUCTIVITY: 3.7e7, - MaterialProperty.PERMITTIVITY: 1, - MaterialProperty.PERMEABILITY: 1, - MaterialProperty.DIELECTRIC_LOSS_TANGENT: 0, + MaterialDef.MaterialProperty.CONDUCTIVITY: 3.7e7, + MaterialDef.MaterialProperty.PERMITTIVITY: 1, + MaterialDef.MaterialProperty.PERMEABILITY: 1, + MaterialDef.MaterialProperty.DIELECTRIC_LOSS_TANGENT: 0, }, ) coil_path.set_hfss_prop("Coil_Mat", True) diff --git a/tests/settings.py b/tests/e2e/settings.py similarity index 100% rename from tests/settings.py rename to tests/e2e/settings.py diff --git a/tests/e2e/unit_tests/test_cell.py b/tests/e2e/unit_tests/test_cell.py new file mode 100644 index 0000000000..01442d9c4e --- /dev/null +++ b/tests/e2e/unit_tests/test_cell.py @@ -0,0 +1,10 @@ +def test_get_database(circuit_cell, new_database): + cell_db = circuit_cell.database + assert not cell_db.is_null + assert cell_db.id == new_database.id + + +def test_get_layout(circuit_cell): + cell_lyt = circuit_cell.layout + assert not cell_lyt.is_null + assert circuit_cell.id == cell_lyt.cell.id diff --git a/tests/test_arc_data.py b/tests/mock/test_arc_data.py similarity index 100% rename from tests/test_arc_data.py rename to tests/mock/test_arc_data.py index e8fac0d4b7..6bac43f456 100644 --- a/tests/test_arc_data.py +++ b/tests/mock/test_arc_data.py @@ -3,9 +3,9 @@ from ansys.api.edb.v1 import edb_messages_pb2, point_data_pb2 from google.protobuf import wrappers_pb2 import pytest +from utils.fixtures import * # noqa from ansys.edb import geometry, utility -from utils.fixtures import * # noqa @pytest.mark.parametrize( diff --git a/tests/test_database.py b/tests/mock/test_database.py similarity index 99% rename from tests/test_database.py rename to tests/mock/test_database.py index e3555e96c7..c3706b7b74 100644 --- a/tests/test_database.py +++ b/tests/mock/test_database.py @@ -1,10 +1,11 @@ from typing import List +from utils.fixtures import * # noqa +from utils.test_utils import create_edb_obj_collection_msg, equals + from ansys.edb import database as database from ansys.edb.core.messages import bool_message, empty_message, int64_message, str_message from ansys.edb.layout import Cell -from utils.fixtures import * # noqa -from utils.test_utils import create_edb_obj_collection_msg, equals # Helper fixtures and functions diff --git a/tests/test_metadata.py b/tests/mock/test_metadata.py similarity index 100% rename from tests/test_metadata.py rename to tests/mock/test_metadata.py diff --git a/tests/test_point_data.py b/tests/mock/test_point_data.py similarity index 100% rename from tests/test_point_data.py rename to tests/mock/test_point_data.py index 4e65a76811..8cda2ed738 100644 --- a/tests/test_point_data.py +++ b/tests/mock/test_point_data.py @@ -1,8 +1,8 @@ import ansys.api.edb.v1.edb_messages_pb2 as edb_messages_pb2 +from utils.fixtures import * # noqa import ansys.edb.geometry.point_data as point_data import ansys.edb.utility.value as value -from utils.fixtures import * # noqa @pytest.mark.parametrize( diff --git a/tests/test_terminals.py b/tests/mock/test_terminals.py similarity index 100% rename from tests/test_terminals.py rename to tests/mock/test_terminals.py index 8b8533dfeb..ed562c4172 100644 --- a/tests/test_terminals.py +++ b/tests/mock/test_terminals.py @@ -1,12 +1,12 @@ import ansys.api.edb.v1.layer_pb2 as layer_pb2 import ansys.api.edb.v1.term_pb2 as term_pb2 +from utils.fixtures import * # noqa +from utils.test_utils import create_edb_obj_msgs, equals from ansys.edb import terminal from ansys.edb.core import messages import ansys.edb.layer as layer_api from ansys.edb.utility import PortPostProcessingProp, Rlc -from utils.fixtures import * # noqa -from utils.test_utils import create_edb_obj_msgs, equals @pytest.fixture diff --git a/tests/utils/__init__.py b/tests/mock/utils/__init__.py similarity index 100% rename from tests/utils/__init__.py rename to tests/mock/utils/__init__.py diff --git a/tests/utils/fixtures.py b/tests/mock/utils/fixtures.py similarity index 100% rename from tests/utils/fixtures.py rename to tests/mock/utils/fixtures.py diff --git a/tests/utils/test_utils.py b/tests/mock/utils/test_utils.py similarity index 100% rename from tests/utils/test_utils.py rename to tests/mock/utils/test_utils.py