Skip to content

Commit

Permalink
T694957: Restructuring tests to have a common Setup and Teardown (#81)
Browse files Browse the repository at this point in the history
* T694957: Restructuring tests to have a common Setup and Teardown

* T694957: Add fixtures for end to end unit testing

* T694957: Reorganized test files

* T694957: Fixed import order

* T694957: is_null is a property now

* T694957: Fixed test_spiral_inductor.py

Co-authored-by: dmiller <[email protected]>
  • Loading branch information
kbhagat-ansys and drewm102 authored Sep 28, 2022
1 parent 16fdbdb commit 07f4aa0
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions tests/conftest.py

This file was deleted.

29 changes: 29 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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],
},
)

Expand Down Expand Up @@ -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)
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions tests/e2e/unit_tests/test_cell.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/test_arc_data.py → tests/mock/test_arc_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions tests/test_database.py → tests/mock/test_database.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_point_data.py → tests/mock/test_point_data.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_terminals.py → tests/mock/test_terminals.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 07f4aa0

Please sign in to comment.