diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 01627872..e9af315e 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -125,7 +125,7 @@ jobs: CONCEPTEV_PASSWORD: ${{ secrets.CONCEPTEV_PASSWORD }} POETRY_VIRTUALENVS_CREATE: ${{ vars.POETRY_VIRTUALENVS_CREATE }} with: - pytest-extra-args: "-m 'not integration' --cov=ansys --cov-report=term --cov-report=html:.cov/html" + pytest-extra-args: "tests/unit --cov=ansys --cov-report=term --cov-report=html:.cov/html" - name: Upload coverage results uses: actions/upload-artifact@v4 @@ -149,12 +149,39 @@ jobs: steps: - uses: ansys/actions/tests-pytest@v10 env: - PYCONCEPTEV_SETTINGS: "tests/config.toml" + PYCONCEPTEV_SETTINGS: "tests/integration/config.toml" CONCEPTEV_PASSWORD: ${{ secrets.CONCEPTEV_PASSWORD }} POETRY_VIRTUALENVS_CREATE: ${{ vars.POETRY_VIRTUALENVS_CREATE }} with: python-version: ${{ env.MAIN_PYTHON_VERSION }} - pytest-extra-args: "-s -m integration --log-cli-level=INFO" + pytest-extra-args: "tests/integration" + tests-e2e: + name: E2E Tests + runs-on: ubuntu-22.04 + timeout-minutes: 2160 + # needs: [ tests ] + container: + image: ${{ format('ghcr.io/ansys/optislang:{0}-jammy', '25.2.0') }} + credentials: + username: ansys-bot + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: "Install Poetry" + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: "Pytest" + env: + PYOPTISLANG_DISABLE_OPTISLANG_OUTPUT: true + ANSYSLMD_LICENSE_FILE: ${{ format('1055@{0}', secrets.LICENSE_SERVER) }} + CONCEPTEV_PASSWORD: ${{ secrets.CONCEPTEV_PASSWORD }} + PYCONCEPTEV_SETTINGS: "tests/e2e/config.toml" + uses: ansys/actions/tests-pytest@v10 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + pytest-extra-args: "tests/e2e" doc-build: name: Build documentation runs-on: ubuntu-latest diff --git a/doc/changelog.d/261.miscellaneous.md b/doc/changelog.d/261.miscellaneous.md new file mode 100644 index 00000000..5cb4f9be --- /dev/null +++ b/doc/changelog.d/261.miscellaneous.md @@ -0,0 +1 @@ +Feature/optislang integration test \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index af6c35b3..0e3d7808 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. [[package]] name = "accessible-pygments" @@ -1342,7 +1342,7 @@ description = "Read resources from Python packages" optional = false python-versions = ">=3.9" groups = ["doc"] -markers = "python_version < \"3.10\"" +markers = "python_version == \"3.9\"" files = [ {file = "importlib_resources-6.5.2-py3-none-any.whl", hash = "sha256:789cfdc3ed28c78b67a06acb8126751ced69a3d5f79c095a98298cd8a760ccec"}, {file = "importlib_resources-6.5.2.tar.gz", hash = "sha256:185f87adef5bcc288449d98fb4fba07cea78bc036455dd44c5fc4a2fe78fed2c"}, @@ -1818,14 +1818,14 @@ test = ["jupyter-server (>=2.0.0)", "pytest (>=7.0)", "pytest-jupyter[server] (> [[package]] name = "jupyterlab" -version = "4.4.4" +version = "4.4.3" description = "JupyterLab computational environment" optional = false python-versions = ">=3.9" groups = ["doc"] files = [ - {file = "jupyterlab-4.4.4-py3-none-any.whl", hash = "sha256:711611e4f59851152eb93316c3547c3ec6291f16bb455f1f4fa380d25637e0dd"}, - {file = "jupyterlab-4.4.4.tar.gz", hash = "sha256:163fee1ef702e0a057f75d2eed3ed1da8a986d59eb002cbeb6f0c2779e6cd153"}, + {file = "jupyterlab-4.4.3-py3-none-any.whl", hash = "sha256:164302f6d4b6c44773dfc38d585665a4db401a16e5296c37df5cba63904fbdea"}, + {file = "jupyterlab-4.4.3.tar.gz", hash = "sha256:a94c32fd7f8b93e82a49dc70a6ec45a5c18281ca2a7228d12765e4e210e5bca2"}, ] [package.dependencies] @@ -2347,46 +2347,19 @@ broker = ["pymsalruntime (>=0.14,<0.18) ; python_version >= \"3.6\" and platform [[package]] name = "msal-extensions" -version = "1.3.1" +version = "1.2.0" description = "Microsoft Authentication Library extensions (MSAL EX) provides a persistence API that can save your data on disk, encrypted on Windows, macOS and Linux. Concurrent data access will be coordinated by a file lock mechanism." optional = false -python-versions = ">=3.9" +python-versions = ">=3.7" groups = ["main"] files = [ - {file = "msal_extensions-1.3.1-py3-none-any.whl", hash = "sha256:96d3de4d034504e969ac5e85bae8106c8373b5c6568e4c8fa7af2eca9dbe6bca"}, - {file = "msal_extensions-1.3.1.tar.gz", hash = "sha256:c5b0fd10f65ef62b5f1d62f4251d51cbcaf003fcedae8c91b040a488614be1a4"}, + {file = "msal_extensions-1.2.0-py3-none-any.whl", hash = "sha256:cf5ba83a2113fa6dc011a254a72f1c223c88d7dfad74cc30617c4679a417704d"}, + {file = "msal_extensions-1.2.0.tar.gz", hash = "sha256:6f41b320bfd2933d631a215c91ca0dd3e67d84bd1a2f50ce917d5874ec646bef"}, ] [package.dependencies] msal = ">=1.29,<2" - -[package.extras] -portalocker = ["portalocker (>=1.4,<4)"] - -[[package]] -name = "narwhals" -version = "1.44.0" -description = "Extremely lightweight compatibility layer between dataframe libraries" -optional = false -python-versions = ">=3.9" -groups = ["dev"] -files = [ - {file = "narwhals-1.44.0-py3-none-any.whl", hash = "sha256:a170ea0bab4cf1f323d9f8bf17f2d7042c3d73802bea321996b39bf075d57de5"}, - {file = "narwhals-1.44.0.tar.gz", hash = "sha256:8cf0616d4f6f21225b3b56fcde96ccab6d05023561a0f162402aa9b8c33ad31d"}, -] - -[package.extras] -cudf = ["cudf (>=24.10.0)"] -dask = ["dask[dataframe] (>=2024.8)"] -duckdb = ["duckdb (>=1.0)"] -ibis = ["ibis-framework (>=6.0.0)", "packaging", "pyarrow-hotfix", "rich"] -modin = ["modin"] -pandas = ["pandas (>=1.1.3)"] -polars = ["polars (>=0.20.3)"] -pyarrow = ["pyarrow (>=11.0.0)"] -pyspark = ["pyspark (>=3.5.0)"] -pyspark-connect = ["pyspark[connect] (>=3.5.0)"] -sqlframe = ["sqlframe (>=3.22.0)"] +portalocker = ">=1.4,<3" [[package]] name = "nbclient" @@ -2604,20 +2577,26 @@ files = [ [[package]] name = "numpydoc" -version = "1.9.0" +version = "1.8.0" description = "Sphinx extension to support docstrings in Numpy format" optional = false python-versions = ">=3.9" groups = ["doc"] files = [ - {file = "numpydoc-1.9.0-py3-none-any.whl", hash = "sha256:8a2983b2d62bfd0a8c470c7caa25e7e0c3d163875cdec12a8a1034020a9d1135"}, - {file = "numpydoc-1.9.0.tar.gz", hash = "sha256:5fec64908fe041acc4b3afc2a32c49aab1540cf581876f5563d68bb129e27c5b"}, + {file = "numpydoc-1.8.0-py3-none-any.whl", hash = "sha256:72024c7fd5e17375dec3608a27c03303e8ad00c81292667955c6fea7a3ccf541"}, + {file = "numpydoc-1.8.0.tar.gz", hash = "sha256:022390ab7464a44f8737f79f8b31ce1d3cfa4b4af79ccaa1aac5e8368db587fb"}, ] [package.dependencies] sphinx = ">=6" +tabulate = ">=0.8.10" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +[package.extras] +developer = ["pre-commit (>=3.3)", "tomli ; python_version < \"3.11\""] +doc = ["intersphinx-registry", "matplotlib (>=3.5)", "numpy (>=1.22)", "pydata-sphinx-theme (>=0.13.3)", "sphinx (>=7)"] +test = ["matplotlib", "pytest", "pytest-cov"] + [[package]] name = "odfpy" version = "1.4.1" @@ -2673,54 +2652,54 @@ files = [ [[package]] name = "pandas" -version = "2.3.0" +version = "2.2.3" description = "Powerful data structures for data analysis, time series, and statistics" optional = false python-versions = ">=3.9" groups = ["doc"] files = [ - {file = "pandas-2.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:625466edd01d43b75b1883a64d859168e4556261a5035b32f9d743b67ef44634"}, - {file = "pandas-2.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a6872d695c896f00df46b71648eea332279ef4077a409e2fe94220208b6bb675"}, - {file = "pandas-2.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f4dd97c19bd06bc557ad787a15b6489d2614ddaab5d104a0310eb314c724b2d2"}, - {file = "pandas-2.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:034abd6f3db8b9880aaee98f4f5d4dbec7c4829938463ec046517220b2f8574e"}, - {file = "pandas-2.3.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:23c2b2dc5213810208ca0b80b8666670eb4660bbfd9d45f58592cc4ddcfd62e1"}, - {file = "pandas-2.3.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:39ff73ec07be5e90330cc6ff5705c651ace83374189dcdcb46e6ff54b4a72cd6"}, - {file = "pandas-2.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:40cecc4ea5abd2921682b57532baea5588cc5f80f0231c624056b146887274d2"}, - {file = "pandas-2.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8adff9f138fc614347ff33812046787f7d43b3cef7c0f0171b3340cae333f6ca"}, - {file = "pandas-2.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e5f08eb9a445d07720776df6e641975665c9ea12c9d8a331e0f6890f2dcd76ef"}, - {file = "pandas-2.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fa35c266c8cd1a67d75971a1912b185b492d257092bdd2709bbdebe574ed228d"}, - {file = "pandas-2.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14a0cc77b0f089d2d2ffe3007db58f170dae9b9f54e569b299db871a3ab5bf46"}, - {file = "pandas-2.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:c06f6f144ad0a1bf84699aeea7eff6068ca5c63ceb404798198af7eb86082e33"}, - {file = "pandas-2.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ed16339bc354a73e0a609df36d256672c7d296f3f767ac07257801aa064ff73c"}, - {file = "pandas-2.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:fa07e138b3f6c04addfeaf56cc7fdb96c3b68a3fe5e5401251f231fce40a0d7a"}, - {file = "pandas-2.3.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:2eb4728a18dcd2908c7fccf74a982e241b467d178724545a48d0caf534b38ebf"}, - {file = "pandas-2.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b9d8c3187be7479ea5c3d30c32a5d73d62a621166675063b2edd21bc47614027"}, - {file = "pandas-2.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9ff730713d4c4f2f1c860e36c005c7cefc1c7c80c21c0688fd605aa43c9fcf09"}, - {file = "pandas-2.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba24af48643b12ffe49b27065d3babd52702d95ab70f50e1b34f71ca703e2c0d"}, - {file = "pandas-2.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:404d681c698e3c8a40a61d0cd9412cc7364ab9a9cc6e144ae2992e11a2e77a20"}, - {file = "pandas-2.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:6021910b086b3ca756755e86ddc64e0ddafd5e58e076c72cb1585162e5ad259b"}, - {file = "pandas-2.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:094e271a15b579650ebf4c5155c05dcd2a14fd4fdd72cf4854b2f7ad31ea30be"}, - {file = "pandas-2.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:2c7e2fc25f89a49a11599ec1e76821322439d90820108309bf42130d2f36c983"}, - {file = "pandas-2.3.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c6da97aeb6a6d233fb6b17986234cc723b396b50a3c6804776351994f2a658fd"}, - {file = "pandas-2.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb32dc743b52467d488e7a7c8039b821da2826a9ba4f85b89ea95274f863280f"}, - {file = "pandas-2.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:213cd63c43263dbb522c1f8a7c9d072e25900f6975596f883f4bebd77295d4f3"}, - {file = "pandas-2.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:1d2b33e68d0ce64e26a4acc2e72d747292084f4e8db4c847c6f5f6cbe56ed6d8"}, - {file = "pandas-2.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:430a63bae10b5086995db1b02694996336e5a8ac9a96b4200572b413dfdfccb9"}, - {file = "pandas-2.3.0-cp313-cp313-win_amd64.whl", hash = "sha256:4930255e28ff5545e2ca404637bcc56f031893142773b3468dc021c6c32a1390"}, - {file = "pandas-2.3.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:f925f1ef673b4bd0271b1809b72b3270384f2b7d9d14a189b12b7fc02574d575"}, - {file = "pandas-2.3.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e78ad363ddb873a631e92a3c063ade1ecfb34cae71e9a2be6ad100f875ac1042"}, - {file = "pandas-2.3.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:951805d146922aed8357e4cc5671b8b0b9be1027f0619cea132a9f3f65f2f09c"}, - {file = "pandas-2.3.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a881bc1309f3fce34696d07b00f13335c41f5f5a8770a33b09ebe23261cfc67"}, - {file = "pandas-2.3.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:e1991bbb96f4050b09b5f811253c4f3cf05ee89a589379aa36cd623f21a31d6f"}, - {file = "pandas-2.3.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:bb3be958022198531eb7ec2008cfc78c5b1eed51af8600c6c5d9160d89d8d249"}, - {file = "pandas-2.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9efc0acbbffb5236fbdf0409c04edce96bec4bdaa649d49985427bd1ec73e085"}, - {file = "pandas-2.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:75651c14fde635e680496148a8526b328e09fe0572d9ae9b638648c46a544ba3"}, - {file = "pandas-2.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf5be867a0541a9fb47a4be0c5790a4bccd5b77b92f0a59eeec9375fafc2aa14"}, - {file = "pandas-2.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:84141f722d45d0c2a89544dd29d35b3abfc13d2250ed7e68394eda7564bd6324"}, - {file = "pandas-2.3.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:f95a2aef32614ed86216d3c450ab12a4e82084e8102e355707a1d96e33d51c34"}, - {file = "pandas-2.3.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:e0f51973ba93a9f97185049326d75b942b9aeb472bec616a129806facb129ebb"}, - {file = "pandas-2.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:b198687ca9c8529662213538a9bb1e60fa0bf0f6af89292eb68fea28743fcd5a"}, - {file = "pandas-2.3.0.tar.gz", hash = "sha256:34600ab34ebf1131a7613a260a61dbe8b62c188ec0ea4c296da7c9a06b004133"}, + {file = "pandas-2.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1948ddde24197a0f7add2bdc4ca83bf2b1ef84a1bc8ccffd95eda17fd836ecb5"}, + {file = "pandas-2.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:381175499d3802cde0eabbaf6324cce0c4f5d52ca6f8c377c29ad442f50f6348"}, + {file = "pandas-2.2.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d9c45366def9a3dd85a6454c0e7908f2b3b8e9c138f5dc38fed7ce720d8453ed"}, + {file = "pandas-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:86976a1c5b25ae3f8ccae3a5306e443569ee3c3faf444dfd0f41cda24667ad57"}, + {file = "pandas-2.2.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b8661b0238a69d7aafe156b7fa86c44b881387509653fdf857bebc5e4008ad42"}, + {file = "pandas-2.2.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:37e0aced3e8f539eccf2e099f65cdb9c8aa85109b0be6e93e2baff94264bdc6f"}, + {file = "pandas-2.2.3-cp310-cp310-win_amd64.whl", hash = "sha256:56534ce0746a58afaf7942ba4863e0ef81c9c50d3f0ae93e9497d6a41a057645"}, + {file = "pandas-2.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:66108071e1b935240e74525006034333f98bcdb87ea116de573a6a0dccb6c039"}, + {file = "pandas-2.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7c2875855b0ff77b2a64a0365e24455d9990730d6431b9e0ee18ad8acee13dbd"}, + {file = "pandas-2.2.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd8d0c3be0515c12fed0bdbae072551c8b54b7192c7b1fda0ba56059a0179698"}, + {file = "pandas-2.2.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c124333816c3a9b03fbeef3a9f230ba9a737e9e5bb4060aa2107a86cc0a497fc"}, + {file = "pandas-2.2.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:63cc132e40a2e084cf01adf0775b15ac515ba905d7dcca47e9a251819c575ef3"}, + {file = "pandas-2.2.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:29401dbfa9ad77319367d36940cd8a0b3a11aba16063e39632d98b0e931ddf32"}, + {file = "pandas-2.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:3fc6873a41186404dad67245896a6e440baacc92f5b716ccd1bc9ed2995ab2c5"}, + {file = "pandas-2.2.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:b1d432e8d08679a40e2a6d8b2f9770a5c21793a6f9f47fdd52c5ce1948a5a8a9"}, + {file = "pandas-2.2.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a5a1595fe639f5988ba6a8e5bc9649af3baf26df3998a0abe56c02609392e0a4"}, + {file = "pandas-2.2.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:5de54125a92bb4d1c051c0659e6fcb75256bf799a732a87184e5ea503965bce3"}, + {file = "pandas-2.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fffb8ae78d8af97f849404f21411c95062db1496aeb3e56f146f0355c9989319"}, + {file = "pandas-2.2.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6dfcb5ee8d4d50c06a51c2fffa6cff6272098ad6540aed1a76d15fb9318194d8"}, + {file = "pandas-2.2.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:062309c1b9ea12a50e8ce661145c6aab431b1e99530d3cd60640e255778bd43a"}, + {file = "pandas-2.2.3-cp312-cp312-win_amd64.whl", hash = "sha256:59ef3764d0fe818125a5097d2ae867ca3fa64df032331b7e0917cf5d7bf66b13"}, + {file = "pandas-2.2.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:f00d1345d84d8c86a63e476bb4955e46458b304b9575dcf71102b5c705320015"}, + {file = "pandas-2.2.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3508d914817e153ad359d7e069d752cdd736a247c322d932eb89e6bc84217f28"}, + {file = "pandas-2.2.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:22a9d949bfc9a502d320aa04e5d02feab689d61da4e7764b62c30b991c42c5f0"}, + {file = "pandas-2.2.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3a255b2c19987fbbe62a9dfd6cff7ff2aa9ccab3fc75218fd4b7530f01efa24"}, + {file = "pandas-2.2.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:800250ecdadb6d9c78eae4990da62743b857b470883fa27f652db8bdde7f6659"}, + {file = "pandas-2.2.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6374c452ff3ec675a8f46fd9ab25c4ad0ba590b71cf0656f8b6daa5202bca3fb"}, + {file = "pandas-2.2.3-cp313-cp313-win_amd64.whl", hash = "sha256:61c5ad4043f791b61dd4752191d9f07f0ae412515d59ba8f005832a532f8736d"}, + {file = "pandas-2.2.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:3b71f27954685ee685317063bf13c7709a7ba74fc996b84fc6821c59b0f06468"}, + {file = "pandas-2.2.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:38cf8125c40dae9d5acc10fa66af8ea6fdf760b2714ee482ca691fc66e6fcb18"}, + {file = "pandas-2.2.3-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ba96630bc17c875161df3818780af30e43be9b166ce51c9a18c1feae342906c2"}, + {file = "pandas-2.2.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1db71525a1538b30142094edb9adc10be3f3e176748cd7acc2240c2f2e5aa3a4"}, + {file = "pandas-2.2.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:15c0e1e02e93116177d29ff83e8b1619c93ddc9c49083f237d4312337a61165d"}, + {file = "pandas-2.2.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:ad5b65698ab28ed8d7f18790a0dc58005c7629f227be9ecc1072aa74c0c1d43a"}, + {file = "pandas-2.2.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:bc6b93f9b966093cb0fd62ff1a7e4c09e6d546ad7c1de191767baffc57628f39"}, + {file = "pandas-2.2.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:5dbca4c1acd72e8eeef4753eeca07de9b1db4f398669d5994086f788a5d7cc30"}, + {file = "pandas-2.2.3-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8cd6d7cc958a3910f934ea8dbdf17b2364827bb4dafc38ce6eef6bb3d65ff09c"}, + {file = "pandas-2.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99df71520d25fade9db7c1076ac94eb994f4d2673ef2aa2e86ee039b6746d20c"}, + {file = "pandas-2.2.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:31d0ced62d4ea3e231a9f228366919a5ea0b07440d9d4dac345376fd8e1477ea"}, + {file = "pandas-2.2.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:7eee9e7cea6adf3e3d24e304ac6b8300646e2a5d1cd3a3c2abed9101b0846761"}, + {file = "pandas-2.2.3-cp39-cp39-win_amd64.whl", hash = "sha256:4850ba03528b6dd51d6c5d273c46f183f39a9baf3f0143e566b89450965b105e"}, + {file = "pandas-2.2.3.tar.gz", hash = "sha256:4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667"}, ] [package.dependencies] @@ -2931,27 +2910,19 @@ type = ["mypy (>=1.11.2)"] [[package]] name = "plotly" -version = "6.2.0" -description = "An open-source interactive data visualization library for Python" +version = "5.24.1" +description = "An open-source, interactive data visualization library for Python" optional = false python-versions = ">=3.8" groups = ["dev"] files = [ - {file = "plotly-6.2.0-py3-none-any.whl", hash = "sha256:32c444d4c940887219cb80738317040363deefdfee4f354498cc0b6dab8978bd"}, - {file = "plotly-6.2.0.tar.gz", hash = "sha256:9dfa23c328000f16c928beb68927444c1ab9eae837d1fe648dbcda5360c7953d"}, + {file = "plotly-5.24.1-py3-none-any.whl", hash = "sha256:f67073a1e637eb0dc3e46324d9d51e2fe76e9727c892dde64ddf1e1b51f29089"}, + {file = "plotly-5.24.1.tar.gz", hash = "sha256:dbc8ac8339d248a4bcc36e08a5659bacfe1b079390b8953533f4eb22169b4bae"}, ] [package.dependencies] -narwhals = ">=1.15.1" packaging = "*" - -[package.extras] -dev = ["plotly[dev-optional]"] -dev-build = ["build", "jupyter", "plotly[dev-core]"] -dev-core = ["pytest", "requests", "ruff (==0.11.12)"] -dev-optional = ["anywidget", "colorcet", "fiona (<=1.9.6) ; python_version <= \"3.8\"", "geopandas", "inflect", "numpy", "orjson", "pandas", "pdfrw", "pillow", "plotly-geo", "plotly[dev-build]", "plotly[kaleido]", "polars[timezone]", "pyarrow", "pyshp", "pytz", "scikit-image", "scipy", "shapely", "statsmodels", "vaex ; python_version <= \"3.9\"", "xarray"] -express = ["numpy"] -kaleido = ["kaleido (>=1.0.0)"] +tenacity = ">=6.2.0" [[package]] name = "pluggy" @@ -2969,6 +2940,26 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "portalocker" +version = "2.10.1" +description = "Wraps the portalocker recipe for easy usage" +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "portalocker-2.10.1-py3-none-any.whl", hash = "sha256:53a5984ebc86a025552264b459b46a2086e269b21823cb572f8f28ee759e45bf"}, + {file = "portalocker-2.10.1.tar.gz", hash = "sha256:ef1bf844e878ab08aee7e40184156e1151f228f103aa5c6bd0724cc330960f8f"}, +] + +[package.dependencies] +pywin32 = {version = ">=226", markers = "platform_system == \"Windows\""} + +[package.extras] +docs = ["sphinx (>=1.7.1)"] +redis = ["redis"] +tests = ["pytest (>=5.4.1)", "pytest-cov (>=2.8.1)", "pytest-mypy (>=0.8.0)", "pytest-timeout (>=2.1.0)", "redis", "sphinx (>=6.0.0)", "types-redis"] + [[package]] name = "pre-commit" version = "4.2.0" @@ -3241,25 +3232,22 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" [[package]] name = "pydantic-settings" -version = "2.10.1" +version = "2.8.1" description = "Settings management using Pydantic" optional = false -python-versions = ">=3.9" +python-versions = ">=3.8" groups = ["main"] files = [ - {file = "pydantic_settings-2.10.1-py3-none-any.whl", hash = "sha256:a60952460b99cf661dc25c29c0ef171721f98bfcb52ef8d9ea4c943d7c8cc796"}, - {file = "pydantic_settings-2.10.1.tar.gz", hash = "sha256:06f0062169818d0f5524420a360d632d5857b83cffd4d42fe29597807a1614ee"}, + {file = "pydantic_settings-2.8.1-py3-none-any.whl", hash = "sha256:81942d5ac3d905f7f3ee1a70df5dfb62d5569c12f51a5a647defc1c3d9ee2e9c"}, + {file = "pydantic_settings-2.8.1.tar.gz", hash = "sha256:d5c663dfbe9db9d5e1c646b2e161da12f0d734d422ee56f567d0ea2cee4e8585"}, ] [package.dependencies] pydantic = ">=2.7.0" python-dotenv = ">=0.21.0" -typing-inspection = ">=0.4.0" [package.extras] -aws-secrets-manager = ["boto3 (>=1.35.0)", "boto3-stubs[secretsmanager]"] azure-key-vault = ["azure-identity (>=1.16.0)", "azure-keyvault-secrets (>=4.8.0)"] -gcp-secret-manager = ["google-cloud-secret-manager (>=2.23.1)"] toml = ["tomli (>=2.0.1)"] yaml = ["pyyaml (>=6.0.1)"] @@ -3298,7 +3286,7 @@ version = "2.19.1" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" -groups = ["build", "dev", "doc", "tests"] +groups = ["build", "doc"] files = [ {file = "pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c"}, {file = "pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f"}, @@ -3421,27 +3409,26 @@ files = [ [[package]] name = "pytest" -version = "8.4.1" +version = "8.3.5" description = "pytest: simple powerful testing with Python" optional = false -python-versions = ">=3.9" +python-versions = ">=3.8" groups = ["dev", "tests"] files = [ - {file = "pytest-8.4.1-py3-none-any.whl", hash = "sha256:539c70ba6fcead8e78eebbf1115e8b589e7565830d7d006a8723f19ac8a0afb7"}, - {file = "pytest-8.4.1.tar.gz", hash = "sha256:7c67fd69174877359ed9371ec3af8a3d2b04741818c51e5e99cc1742251fa93c"}, + {file = "pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820"}, + {file = "pytest-8.3.5.tar.gz", hash = "sha256:f4efe70cc14e511565ac476b57c279e12a855b11f48f212af1080ef2263d3845"}, ] [package.dependencies] -colorama = {version = ">=0.4", markers = "sys_platform == \"win32\""} -exceptiongroup = {version = ">=1", markers = "python_version < \"3.11\""} -iniconfig = ">=1" -packaging = ">=20" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +iniconfig = "*" +packaging = "*" pluggy = ">=1.5,<2" -pygments = ">=2.7.2" tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests", "setuptools", "xmlschema"] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-asyncio" @@ -3465,20 +3452,19 @@ testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] [[package]] name = "pytest-cov" -version = "6.2.1" +version = "6.1.1" description = "Pytest plugin for measuring coverage." optional = false python-versions = ">=3.9" groups = ["dev", "tests"] files = [ - {file = "pytest_cov-6.2.1-py3-none-any.whl", hash = "sha256:f5bc4c23f42f1cdd23c70b1dab1bbaef4fc505ba950d53e0081d0730dd7e86d5"}, - {file = "pytest_cov-6.2.1.tar.gz", hash = "sha256:25cc6cc0a5358204b8108ecedc51a9b57b34cc6b8c967cc2c01a4e00d8a67da2"}, + {file = "pytest_cov-6.1.1-py3-none-any.whl", hash = "sha256:bddf29ed2d0ab6f4df17b4c55b0a657287db8684af9c42ea546b21b1041b3dde"}, + {file = "pytest_cov-6.1.1.tar.gz", hash = "sha256:46935f7aaefba760e716c2ebfbe1c216240b9592966e7da99ea8292d4d3e2a0a"}, ] [package.dependencies] coverage = {version = ">=7.5", extras = ["toml"]} -pluggy = ">=1.2" -pytest = ">=6.2.5" +pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] @@ -3504,14 +3490,14 @@ testing = ["pytest-asyncio (==0.23.*)", "pytest-cov (==4.*)"] [[package]] name = "pytest-mock" -version = "3.14.1" +version = "3.14.0" description = "Thin-wrapper around the mock package for easier use with pytest" optional = false python-versions = ">=3.8" groups = ["tests"] files = [ - {file = "pytest_mock-3.14.1-py3-none-any.whl", hash = "sha256:178aefcd11307d874b4cd3100344e7e2d888d9791a6a1d9bfe90fbc1b74fd1d0"}, - {file = "pytest_mock-3.14.1.tar.gz", hash = "sha256:159e9edac4c451ce77a5cdb9fc5d1100708d2dd4ba3c3df572f14097351af80e"}, + {file = "pytest-mock-3.14.0.tar.gz", hash = "sha256:2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0"}, + {file = "pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"}, ] [package.dependencies] @@ -3650,14 +3636,14 @@ six = ">=1.5" [[package]] name = "python-dotenv" -version = "1.1.1" +version = "1.0.1" description = "Read key-value pairs from a .env file and set them as environment variables" optional = false -python-versions = ">=3.9" +python-versions = ">=3.8" groups = ["main"] files = [ - {file = "python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc"}, - {file = "python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab"}, + {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"}, + {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"}, ] [package.extras] @@ -3699,8 +3685,7 @@ version = "308" description = "Python for Window Extensions" optional = false python-versions = "*" -groups = ["doc"] -markers = "sys_platform == \"win32\" and platform_python_implementation != \"PyPy\"" +groups = ["main", "doc"] files = [ {file = "pywin32-308-cp310-cp310-win32.whl", hash = "sha256:796ff4426437896550d2981b9c2ac0ffd75238ad9ea2d3bfa67a1abd546d262e"}, {file = "pywin32-308-cp310-cp310-win_amd64.whl", hash = "sha256:4fc888c59b3c0bef905ce7eb7e2106a07712015ea1c8234b703a088d46110e8e"}, @@ -3721,6 +3706,7 @@ files = [ {file = "pywin32-308-cp39-cp39-win32.whl", hash = "sha256:7873ca4dc60ab3287919881a7d4f88baee4a6e639aa6962de25a98ba6b193341"}, {file = "pywin32-308-cp39-cp39-win_amd64.whl", hash = "sha256:71b3322d949b4cc20776436a9c9ba0eeedcbc9c650daa536df63f0ff111bb920"}, ] +markers = {main = "platform_system == \"Windows\"", doc = "sys_platform == \"win32\" and platform_python_implementation != \"PyPy\""} [[package]] name = "pywin32-ctypes" @@ -4608,13 +4594,28 @@ typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\"" [package.extras] full = ["httpx (>=0.27.0,<0.29.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.18)", "pyyaml"] +[[package]] +name = "tabulate" +version = "0.9.0" +description = "Pretty-print tabular data" +optional = false +python-versions = ">=3.7" +groups = ["doc"] +files = [ + {file = "tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f"}, + {file = "tabulate-0.9.0.tar.gz", hash = "sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c"}, +] + +[package.extras] +widechars = ["wcwidth"] + [[package]] name = "tenacity" version = "9.1.2" description = "Retry code until it succeeds" optional = false python-versions = ">=3.9" -groups = ["main"] +groups = ["main", "dev"] files = [ {file = "tenacity-9.1.2-py3-none-any.whl", hash = "sha256:f77bf36710d8b73a50b2dd155c97b870017ad21afe6ab300326b0371b3b05138"}, {file = "tenacity-9.1.2.tar.gz", hash = "sha256:1169d376c297e7de388d18b4481760d478b0e99a777cad3a9c86e556f4b697cb"}, @@ -4731,14 +4732,14 @@ files = [ [[package]] name = "tox" -version = "4.27.0" +version = "4.24.2" description = "tox is a generic virtualenv management and test command line tool" optional = false -python-versions = ">=3.9" +python-versions = ">=3.8" groups = ["dev"] files = [ - {file = "tox-4.27.0-py3-none-any.whl", hash = "sha256:2b8a7fb986b82aa2c830c0615082a490d134e0626dbc9189986da46a313c4f20"}, - {file = "tox-4.27.0.tar.gz", hash = "sha256:b97d5ecc0c0d5755bcc5348387fef793e1bfa68eb33746412f4c60881d7f5f57"}, + {file = "tox-4.24.2-py3-none-any.whl", hash = "sha256:92e8290e76ad4e15748860a205865696409a2d014eedeb796a34a0f3b5e7336e"}, + {file = "tox-4.24.2.tar.gz", hash = "sha256:d5948b350f76fae436d6545a5e87c2b676ab7a0d7d88c1308651245eadbe8aea"}, ] [package.dependencies] @@ -4752,7 +4753,7 @@ pluggy = ">=1.5" pyproject-api = ">=1.8" tomli = {version = ">=2.2.1", markers = "python_version < \"3.11\""} typing-extensions = {version = ">=4.12.2", markers = "python_version < \"3.11\""} -virtualenv = ">=20.31" +virtualenv = ">=20.29.1" [package.extras] test = ["devpi-process (>=1.0.2)", "pytest (>=8.3.4)", "pytest-mock (>=3.14)"] @@ -4825,21 +4826,6 @@ files = [ ] markers = {build = "python_version < \"3.11\"", dev = "python_version < \"3.11\"", tests = "python_version < \"3.13\""} -[[package]] -name = "typing-inspection" -version = "0.4.1" -description = "Runtime typing introspection tools" -optional = false -python-versions = ">=3.9" -groups = ["main"] -files = [ - {file = "typing_inspection-0.4.1-py3-none-any.whl", hash = "sha256:389055682238f53b04f7badcb49b989835495a96700ced5dab2d8feae4b26f51"}, - {file = "typing_inspection-0.4.1.tar.gz", hash = "sha256:6ae134cc0203c33377d43188d4064e9b357dba58cff3185f22924610e70a9d28"}, -] - -[package.dependencies] -typing-extensions = ">=4.12.0" - [[package]] name = "tzdata" version = "2025.1" @@ -4907,14 +4893,14 @@ standard = ["colorama (>=0.4) ; sys_platform == \"win32\"", "httptools (>=0.6.3) [[package]] name = "virtualenv" -version = "20.31.2" +version = "20.29.2" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.8" groups = ["dev"] files = [ - {file = "virtualenv-20.31.2-py3-none-any.whl", hash = "sha256:36efd0d9650ee985f0cad72065001e66d49a6f24eb44d98980f630686243cf11"}, - {file = "virtualenv-20.31.2.tar.gz", hash = "sha256:e10c0a9d02835e592521be48b332b6caee6887f332c111aa79a09b9e79efc2af"}, + {file = "virtualenv-20.29.2-py3-none-any.whl", hash = "sha256:febddfc3d1ea571bdb1dc0f98d7b45d24def7428214d4fb73cc486c9568cce6a"}, + {file = "virtualenv-20.29.2.tar.gz", hash = "sha256:fdaabebf6d03b5ba83ae0a02cfe96f48a716f4fae556461d180825866f75b728"}, ] [package.dependencies] @@ -4924,7 +4910,7 @@ platformdirs = ">=3.9.1,<5" [package.extras] docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] -test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8) ; platform_python_implementation == \"PyPy\" or platform_python_implementation == \"GraalVM\" or platform_python_implementation == \"CPython\" and sys_platform == \"win32\" and python_version >= \"3.13\"", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10) ; platform_python_implementation == \"CPython\""] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8) ; platform_python_implementation == \"PyPy\" or platform_python_implementation == \"CPython\" and sys_platform == \"win32\" and python_version >= \"3.13\"", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10) ; platform_python_implementation == \"CPython\""] [[package]] name = "watchfiles" @@ -5296,4 +5282,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.9,<4.0" -content-hash = "5879bea52912198e350e91caa66c608dbaeb06ac5051e59f598893d747d1adbd" +content-hash = "d3f1fefe3edb29512a747ad2921b5ced2ba69d51834312aeda3bff92c6eac6c2" diff --git a/pyproject.toml b/pyproject.toml index d24b624a..276b7322 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ pytest-mock = "^3.12.0" # Optional build requirements pytest-asyncio = ">=0.24,<1.1" -ansys-optislang-core = ">=0.10,<1.1" +ansys-optislang-core = "^1.0.0" [tool.poetry.group.build] optional = true diff --git a/src/ansys/conceptev/core/ocm.py b/src/ansys/conceptev/core/ocm.py index df004f59..c6658dd0 100644 --- a/src/ansys/conceptev/core/ocm.py +++ b/src/ansys/conceptev/core/ocm.py @@ -256,6 +256,8 @@ def get_status(job_info: dict, token: str) -> str: status = processed_response["finalStatus"].upper() elif "lastStatus" in processed_response and processed_response["lastStatus"] is not None: status = processed_response["lastStatus"].upper() + elif "jobStatus" in processed_response and processed_response["jobStatus"] is not None: + status = processed_response["jobStatus"][0]["jobStatus"].upper() else: raise ResponseError(f"Failed to get job status {processed_response}.") return status diff --git a/tests/config.toml b/tests/e2e/config.toml similarity index 100% rename from tests/config.toml rename to tests/e2e/config.toml diff --git a/tests/e2e/test_optislang_e2e.py b/tests/e2e/test_optislang_e2e.py new file mode 100644 index 00000000..ccaf1da0 --- /dev/null +++ b/tests/e2e/test_optislang_e2e.py @@ -0,0 +1,212 @@ +# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import logging +import os +import shutil + +from ansys.optislang.core import Optislang +import ansys.optislang.core.node_types as node_types +from ansys.optislang.core.nodes import DesignFlow +from ansys.optislang.core.project_parametric import ( + ComparisonType, + ConstraintCriterion, + ObjectiveCriterion, +) +import pytest + + +class QueryHandler(logging.Handler): + def __init__(self, log_filepath=None): + super().__init__() + self._collected_messages = [] + self.log_filepath = log_filepath + + def emit(self, record): + self._collected_messages.append(record.getMessage()) + if self.log_filepath is not None: + with open(str(self.log_filepath), "a") as f: + f.write(record.getMessage() + "\n") + + def get_messages(self): + collected_messages = [msg for msg in self._collected_messages] + self._collected_messages = [] + return collected_messages + + +class LogFilter(logging.Filter): + def __init__(self, level): + super().__init__() + self._level = level + + def filter(self, record): + return record.levelno <= self._level + + +def prepare_logging_facilities(osl_object, working_dir): + osl_object.log.setLevel(logging.DEBUG) + error_handler = QueryHandler(os.path.join(working_dir, "stderr.txt")) + error_handler.setLevel(logging.WARNING) + std_handler = QueryHandler(os.path.join(working_dir, "stdout.txt")) + std_handler.setLevel(logging.DEBUG) + std_handler.addFilter(LogFilter(logging.INFO)) + + osl_object.log.addHandler(std_handler) + osl_object.log.addHandler(error_handler) + + return std_handler, error_handler + + +def register_parameter(node, name): + location = get_input_location_by_name(node, name) + node.register_location_as_parameter( + location=location, + name=name, + ) + + +def get_input_location_by_name(node, name): + input_locations = node.get_available_input_locations() + for loc in input_locations: + if loc["location"]["name"] == name: + return loc["location"] + raise KeyError(f"Input location '{name}' not found.") + + +def get_output_location_by_name(node, name): + output_locations = node.get_available_output_locations() + for loc in output_locations: + if loc["location"]["name"] == name: + return loc["location"] + raise KeyError(f"Output location '{name}' not found.") + + +def register_response(node, name): + location = get_output_location_by_name(node, name) + node.register_location_as_response( + location=location, + name=name, + ) + + +def get_unit_test_dir(): + unit_test_dir = os.path.join(".") + return unit_test_dir + + +def get_working_dir(): + return os.path.join(get_unit_test_dir(), "test_working_dir") + + +def remove_non_empty_dir(path): + if os.path.exists(path): + shutil.rmtree(path, ignore_errors=False, onerror=None) + + +@pytest.mark.e2e +def test_optislang_connection() -> None: + # create fresh working directory + # this is logging in interactively and connecting to prod server at the moment + working_dir = get_working_dir() + opf_filepath = os.path.join(working_dir, "test_conceptev_ci.opf") + opd_dir = os.path.join(working_dir, "test_conceptev_ci.opd") + remove_non_empty_dir(working_dir) + os.makedirs(working_dir) + + osl_project_path = os.path.join(working_dir, "test_conceptev_ci.opf") + + # created concept + # configure environment + design_instance_id = "121222c8-f2e8-4fa2-84fb-69336bbdc548" + osl = Optislang(project_path=osl_project_path) + print(osl) + osl.osl_server.timeouts_register.default_value = 180 + std_handler, err_handler = prepare_logging_facilities(osl, working_dir) + + root_system = osl.application.project.root_system + sensitivity = root_system.create_node(type_=node_types.Sensitivity) + concept_ev_node_type = node_types.NodeType( + id="conceptev", + subtype=node_types.AddinType.PYTHON_BASED_INTEGRATION_PLUGIN, + osl_class_type=node_types.NodeClassType.INTEGRATION_NODE, + ) + node_name = "conceptev" + cev_node = sensitivity.create_node( + type_=concept_ev_node_type, + name=node_name, + design_flow=DesignFlow.RECEIVE_SEND, + ) + non_modifying_settings = cev_node.get_property("NonModifyingSettings") + non_modifying_settings["cev_account_name"] = "ConceptEv Test Account" + cev_node.set_property("NonModifyingSettings", non_modifying_settings) + modifying_settings = cev_node.get_property("ModifyingSettings") + modifying_settings["cev_concept_id"] = design_instance_id + cev_node.set_property("ModifyingSettings", modifying_settings) + cev_node.load() + + input_locations = cev_node.get_available_input_locations() + output_locations = cev_node.get_available_output_locations() + register_parameter(cev_node, "rear_motor") + + register_response(cev_node, "_00__capability_curve__torque_vs_speed") + register_response(cev_node, "_02__summary__cost") + register_response(cev_node, "_02__summary__mass") + register_response(cev_node, "_02__summary__constraints_fulfilled") + register_response(cev_node, "_02__summary__n_constraints_fulfilled") + + sensitivity.criteria_manager.add_criterion( + ObjectiveCriterion( + name="obj_cost", expression="_02__summary__cost", criterion=ComparisonType.MIN + ) + ) + sensitivity.criteria_manager.add_criterion( + ConstraintCriterion( + name="constraints_fulfilled", + expression="_02__summary__n_constraints_fulfilled", + criterion=ComparisonType.GREATEREQUAL, + limit_expression="1", + ) + ) + + # limit the number of designs to compute + algo_settings = sensitivity.get_property("AlgorithmSettings") + algo_settings["num_discretization"] = 10 + sensitivity.set_property("AlgorithmSettings", algo_settings) + + # define parallelism + cev_node.set_property("MaxParallel", 10) + + # define max runtime + cev_node.set_property("MaxRuntime", 180000) # milliseconds + + # save + osl.application.save() + + # run + osl.application.project.start() + + # save and close + osl.application.save() + osl.dispose() + + stderr = "".join(err_handler.get_messages()) + stdout = "".join(std_handler.get_messages()) diff --git a/tests/old_config.toml b/tests/integration/config.toml similarity index 78% rename from tests/old_config.toml rename to tests/integration/config.toml index 7721ab56..5c524632 100644 --- a/tests/old_config.toml +++ b/tests/integration/config.toml @@ -1,8 +1,9 @@ OCM_URL = "https://dev.portal.onscale.com/api" OCM_SOCKET_URL = "wss://sockets.dev.portal.onscale.com/socket" CONCEPTEV_URL = "https://test-conceptev.awsansys3np.onscale.com/api" -client_id = "9c9edb71-06f9-4c4b-afed-9201668385de" +client_id = "743c94e3-c72d-4ace-b9ee-ab5c3cbe6504" authority = "https://a365dev.b2clogin.com/a365dev.onmicrosoft.com/b2c_1a_ansysid_signup_signin_test" scope = "https://a365dev.onmicrosoft.com/AnsysID/Authentication" conceptev_username = "conceptev_testing@ansys.com" -account_name = "ConceptEv Test Account" \ No newline at end of file +account_name = "ConceptEv Test Account" +job_timeout = 3600 \ No newline at end of file diff --git a/tests/integration/e9.lab b/tests/integration/e9.lab new file mode 100644 index 00000000..f9fb25b2 --- /dev/null +++ b/tests/integration/e9.lab @@ -0,0 +1 @@ +{"LabModelExportFilePath": "C:\\Workspace\\ConceptEV\\ConceptEV\\ConceptEV-API\\data\\Lab_Data\\e9.lab", "TimeoutMultiplier_Lab": 1, "MessageDisplayState": 0, "MotorType_MotorLAB": "BPM", "CurrentMotFilePath_MotorLAB": "C:\\Ansys_Motor-CAD\\2024_0_4\\Motor-CAD Data\\templates\\e9_eMobility_IPM.mtt", "ResultsPath_MotorLAB": "C:\\Ansys_Motor-CAD\\2024_0_4\\Motor-CAD Data\\templates\\e9_eMobility_IPM\\Lab\\", "ComparisonPath_Lab": "", "UserLoadedResultsFile_Lab": "", "ElectroLink_MotorLAB": "Motor-CAD EMag", "DrivCycle_MotorLAB": 3, "Duty_Cycle_Definition": 3, "Duty_Cycle_SyncCurrentLimit_Method_Lab": 1, "DutyCycleType_Lab": 1, "ExpData_MotorLAB": "False", "ExpDataType_MotorLAB": 0, "ExpDataPath_MotorLAB": "", "CurrentExeDir_MotorLAB": "C:\\Ansys_Motor-CAD\\2024_0_4\\", "AutoShowResults_MotorLAB": "True", "SaturationMap_InputDefinition": 0, "SaturationMap_CalculationMethod": 0, "SaturationMap_FEACalculationType": 1, "SaturationMap_ResultType": 0, "SaturationMap_FieldCurrentDefinition": 0, "SaturationMap_Export": true, "LossMap_Export": true, "SaturationMap_ExportToCSV": false, "SaturationMap_StatorCurrentMax": 150.0, "SaturationMap_StatorCurrentStep": 30.0, "SaturationMap_StatorCurrentMin": 0.0, "SaturationMap_PhaseAdvanceMax": 90.0, "SaturationMap_PhaseAdvanceStep": 22.5, "SaturationMap_PhaseAdvanceMin": 0.0, "SaturationMap_Current_D_Max": 0.0, "SaturationMap_Current_D_Step": 30.0, "SaturationMap_Current_D_Min": -150.0, "SaturationMap_Current_Q_Max": 150.0, "SaturationMap_Current_Q_Step": 30.0, "SaturationMap_Current_Q_Min": 0.0, "SaturationMap_FieldCurrentMax": 12.0, "SaturationMap_FieldCurrentStep": 4.0, "SaturationMap_FieldCurrentMin": 0.0, "ModelBuildSpeed_MotorLAB": 10000.0, "ModelBuildSpeed_Min_Lab": 50.0, "LossMap_Speed": 3000.0, "SpeedVariationType_Lab": 0, "SaturationMap_ExportFile": "", "SaturationModelInterpolation_Lab": 0, "MaxModelCurrent_MotorLAB": 480.0, "MaxModelCurrent_RMS_MotorLAB": 339.411254969543, "CalcTypeCuLoss_MotorLAB": 0, "SleeveLossCalc_Lab": 0, "BandingLossCalc_Lab": 0, "IronLossCalculationType": 0, "ProximityLossModel": 0, "HybridAdjustmentFactor_ACLosses": 1.0, "AcLossFreq_MotorLAB": 2.0, "n2ac_MotorLAB": 3000.0, "RacRdc_MotorLAB": 2.0, "StatorCopperFreqCompTempExponent": 0.5, "StatorConductor_Resistivity": 2.02361396e-08, "ACLosses_BundleHeight": 3.39411254969543, "NumberOfCuboids": 2, "NumberOfCuboids_LossModel_Lab": 2, "ACConductorLossProportion_Lab": [0.0, 0.0], "ACConductorLossSplit_Lab": 0, "ACLossSpeedScalingMethod_Lab": 1, "ACLossHighFrequencyScaling_Method": 1, "ACLossGeneratorMethod_Lab": 1, "TurnsRef_MotorLAB": 6.0, "TurnsCalc_MotorLAB": 6.0, "ResistanceTurnsRef_MotorLAB": 6.0, "Length_Calc_Lab": 160.0, "Length_Ref_Lab": 160.0, "Length_Ref_Resistance_Lab": 160.0, "LossModelBuildPoints_Lab": 30, "ACLossModelBuildPoints_Lab": 30, "LossModel_Is_Lab": [0.0, 0.0, 0.0, 0.0, 0.0, 96.0, 96.0, 96.0, 96.0, 96.0, 192.0, 192.0, 192.0, 192.0, 192.0, 288.0, 288.0, 288.0, 288.0, 288.0, 384.0, 384.0, 384.0, 384.0, 384.0, 480.0, 480.0, 480.0, 480.0, 480.0], "LossModel_Gamma_Lab": [0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0], "FEALossMap_RefSpeed_Lab": 500.0, "IronLossBuildFactorDefinition": 0, "EddyLossBuildFactor": 1.0, "StatorIronLossBuildFactor": 1.5, "RotorIronLossBuildFactor": 1.5, "HysteresisLossBuildFactor": 1.0, "RotorLaminations": 0, "RotorIronEddyLossExponent_Lab": 2.0, "Pole_MotorLAB": 8.0, "TorqueDemand_MotorLAB": 200.0, "Housing_Water_Jacket": true, "Shaft_Spiral_Groove": false, "BPM_FilePath_MotorLAB": "", "EmagneticCalcType_Lab": 1, "MaxSpeedTherm_MotorLAB": 10000.0, "SpeedStepTherm_MotorLAB": 500.0, "MinSpeedTherm_Lab": 200.0, "MaxWindTemp_MotorLAB": 160.0, "ThermCalcType_MotorLAB": 0, "MaxWindingSpec_MotorLAB": 0, "TempLimit_MotorLAB": 1, "ThermalMapType_Lab": 0, "Iest_MotorLAB": 240.0, "Iest_RMS_MotorLAB": 169.705627484771, "ThermalConvergenceMethod_Lab": 1, "ThermalStatorWindingTemperatureMethod_Lab": 1, "Thermal_TemperaturesForEMag_Lab": 1, "ThermalEnvelopeSensitivity_Lab": 1.0, "RotorTemperatureTolerance_Lab": 1.0, "RotorTemperatureMaxIterations_Lab": 20, "RotorTemperatureIterationsBeforeAverage_Lab": 4, "RotorTemperatureIterationsInAverage_Lab": 3, "RotorTemperatureMaxDivergingSteps_Lab": 5, "RotorWindingTemp_Ref_Lab": 20.0, "RotorWindingTemp_Calc_Lab": 20.0, "Twdg_MotorLAB": 65.0, "Imax_MotorLAB": 480.0, "Imax_RMS_MotorLAB": 339.411254969543, "Imin_MotorLAB": 1.0, "Imin_RMS_MotorLAB": 0.707106781186547, "Iinc_MotorLAB": 30, "WindingTemp_ACLoss_Ref_Lab": 20.0, "PrevCalcImin_MotorLAB": 1.0, "PrevCalcIinc_MotorLAB": 30, "PrevCalcImax_MotorLAB": 480.0, "SpeedMax_MotorLAB": 10000.0, "SpeedMin_MotorLAB": 0.0, "SpeedInc_MotorLAB": 500.0, "IronLossModelSplit_Lab": 0, "IronLossModelSplit_Stator_Lab": 0, "IronLossModelSplit_Rotor_Lab": 0, "LossProp_Stator_Lab": 0.9, "LossProp_Rotor_Lab": 0.1, "LossProp_StatorBackIron_Lab": 0.45, "LossProp_StatorTooth_Lab": 0.55, "LossProp_RotorBackIron_Lab": 1.0, "LossProp_RotorPole_Lab": 0.0, "StatorCurrentDemand_Lab": 150.0, "StatorCurrentDemand_RMS_Lab": 106.066017177982, "SpeedDemand_MotorLAB": 1000.0, "PhaseAdvanceDemand_Lab": 0.0, "SlipDemand_Lab": 0.01, "StatorTempDemand_Lab": 160.0, "RotorTempDemand_Lab": 140.0, "OperatingMode_Lab": 2, "ThermMaxCurrentLim_MotorLAB": "False", "CurrentSpec_MotorLAB": 0, "TestType_MotorLAB": 0, "TestSpeedMin_MotorLAB": 10.0, "TestSpeedInc_MotorLAB": 10.0, "TestSpeedMax_MotorLAB": 1000.0, "Slots_MotorLAB": 48.0, "TwindingCalc_MotorLAB": 65.0, "Windage_Loss_Definition": 0, "BearingLossSource": 0, "Airgap_Temperature": 20.0, "Bearing_Temperature_F": 20.0, "Bearing_Temperature_R": 20.0, "Windage_Loss_@Ref_Speed": 0.0, "Ref_Speed_-_Windage_Loss": 3000.0, "Speed_Coeff_-_Windage_Loss": 3.0, "Friction_Loss_[F]_@Ref_Speed": 25.0, "Ref_Speed_-_Friction_Loss_[F]": 10000.0, "Speed_Coeff_-_Friction_Loss_[F]": 1.0, "Friction_Loss_[R]_@Ref_Speed": 25.0, "Ref_Speed_-_Friction_Loss_[R]": 10000.0, "Speed_Coeff_-_Friction_Loss_[R]": 1.0, "WindingAlpha_MotorLAB": 0.003862, "OpPointSpec_MotorLAB": 0, "MaxNumAltStartPoints_Lab": 2, "MinTorque_MotorLAB": 10.0, "TorqueInc_MotorLAB": 10.0, "TorqueMax_MotorLAB": 100.0, "LabThermalCoupling": 0, "LabMagneticCoupling": 0, "BuildSatModel_MotorLAB": "True", "BuildLossModel_MotorLAB": "True", "MaxRotorTemp_Lab": 160.0, "RotorCurrentEstimate_Lab": 6.0, "Resistance_MotorLAB": 0.0133773639742649, "EndWindingResistance_Lab": 0.00478887958376453, "EndWindingResistance_Field_Lab": 0.001, "EndWindingInductance_Lab": 5.2350555459915e-06, "ExternalLine_Resistance": 0.0, "Gen_Load_Definition_Lab": 0, "Gen_Load_Connection_Lab": 0, "Gen_Speed_Fixed_Lab": false, "Gen_Speed_Max_Lab": 6000.0, "Gen_Speed_Min_Lab": 0.0, "Gen_Speed_Step_Lab": 500.0, "Gen_Impedance_Fixed_Lab": false, "Gen_Impedance_Max_Lab": 10.0, "Gen_Impedance_Min_Lab": 1.0, "Gen_Impedance_Step_Lab": 1.0, "Gen_PF_Fixed_Lab": true, "Gen_PF_Max_Lab": 1.0, "Gen_PF_Min_Lab": 0.5, "Gen_PF_Step_Lab": 0.1, "Gen_Resistance_Fixed_Lab": false, "Gen_Resistance_Max_Lab": 10.0, "Gen_Resistance_Min_Lab": 1.0, "Gen_Resistance_Step_Lab": 1.0, "Gen_Inductance_Fixed_Lab": true, "Gen_Inductance_Max_Lab": 0.01, "Gen_Inductance_Min_Lab": 0.001, "Gen_Inductance_Step_Lab": 0.001, "Motor_Type": 0, "BPMDriveMode": 0, "DriveType_BPM": 0, "MagPhases": 3, "MagPhaseDistribution": 0, "WindingConnection": 0, "CustomDriveCyclePeakLineCurrent": 0.0, "CustomDriveFundamentalAmplitude": 0.0, "CustomDriveCyclePeakAmplitude": 0.0, "Lab_Threads_Enabled": true, "VoltageConversionFactor": 1.73205080756888, "FastRotorSkew_Lab": 1, "SkewType": 0, "StatorSkew": 0.0, "ContinuousSkewMethod": 1, "DCCurrentLimitExternaLine_Method_Lab": 1, "ElectricalCustomLoss_Method_Lab": 1, "NumCustomLossesInternal_Lab": 0, "CustomLoss_Name_Internal_Lab": [], "CustomLoss_Function_Internal_Lab": [], "CustomLoss_Type_Internal_Lab": [], "CustomLoss_ThermalNode_Internal_Lab": [], "NumCustomLossesExternal_Lab": 0, "CustomLoss_Name_External_Lab": [], "CustomLoss_PowerFunction_External_Lab": [], "CustomLoss_VoltageFunction_External_Lab": [], "CustomLoss_AllowedValues_Lab": 1, "NumCustomThermalLimits_Lab": 0, "CustomThermalLimitNode_Lab": [], "CustomThermalLimitTemperature_Lab": [], "CustomThermalLimit_Lab": [], "CustomThermalLimitName_Lab": [], "ModulationIndex_MotorLAB": 1.0, "DCBusVoltage": 400.0, "DCCurrentLimit_Lab": 0, "MaxDCCurrent_Lab": 80.0, "ModelType_MotorLAB": 2, "Ah_MotorLAB": 0.0, "Ae_MotorLAB": 0.0, "Bh_MotorLAB": 0.0, "Be_MotorLAB": 0.0, "Wmag_MotorLAB": 0.0, "WmagOC_MotorLAB": 0.0, "Imag_MotorLAB": 0.0, "Nmag_MotorLAB": 500.0, "NonSalient_MotorLAB": "False", "SatModelPoints_MotorLAB": 1, "SaturationModelMethod_Lab": 1, "ACLossModelBuildPoints_Current_Lab": 4, "ACLossModelBuildPoints_Gamma_Lab": 4, "ACLossModelBuildPoints_Speed_Lab": 4, "ModelBuildGammaDistribution_Lab": 1, "MagLossCoeff_MotorLAB": 1.961416686, "XEndLeak_MotorLAB": 1.0, "BrTempCoeff_MotorLAB": -0.152201067761, "MaxMagnet_MotorLAB": 140.0, "MagnetLossCalc_Lab": 3, "IronLossCalc_Lab": 3, "Tmag_MotorLAB": 65.0, "Ld_MotorLAB": 0.000177569943091, "Lq_MotorLAB": 0.000377775325555, "LamM_MotorLAB": 0.0664977490569, "Isc_MotorLAB": 333.3210673, "LEndWdg_MotorLAB": 0.0, "Vdrop_MotorLAB": "True", "SyncRel_MotorLAB": "False", "UseMagnetTempLinkMethod_Lab": 1, "MagnetTempLinkMethod": 1, "ControlStrat_MotorLAB": 0, "NumControlStrategyPoints_Lab": 3, "StatorCurrentLimit_Lab": 1, "InitialCurrentMethod_Lab": 2, "PowerLimVal_MotorLAB": 0.0, "PowerLim_MotorLAB": "False", "TmagnetCalc_MotorLAB": 65.0, "MagnetLossBuildFactor": 1.0, "SmoothMap_MotorLAB": "True", "psiQ_coeff_MotorLAB": [-1.22459892871e-05, 3.34643823614e-06, 0.000734275638415, 7.72218232657e-09, 1.34719426451e-07, -1.12352185242e-06, -5.21543393588e-10, -1.95539099677e-09, -8.07630141653e-10, 4.85923773117e-13, 2.93356614477e-12, 2.42672711631e-12], "psiD_coeff_MotorLAB": [0.0762214253879, 0.000243247674634, 1.01959934716e-05, 4.37265613089e-08, -2.55805901475e-08, -5.7053314445e-08, -1.95996475722e-10, -1.07471703618e-09, -4.0166792834e-10, -7.54451200575e-14, 1.43540494391e-12, 6.85215135725e-13], "SatModelBuildPoints_Lab": 30, "Sync_IrSatModel_Lab": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "SatModel_Is_Lab": [0.0, 0.0, 0.0, 0.0, 0.0, 96.0, 96.0, 96.0, 96.0, 96.0, 192.0, 192.0, 192.0, 192.0, 192.0, 288.0, 288.0, 288.0, 288.0, 288.0, 384.0, 384.0, 384.0, 384.0, 384.0, 480.0, 480.0, 480.0, 480.0, 480.0], "SatModel_Gamma_Lab": [0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0, 0.0, 22.5, 45.0, 67.5, 90.0], "SatModel_Speed_Lab": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "PsiDModel_Lab": [0.076206425986, 0.076206425986, 0.076206425986, 0.076206425986, 0.076206425986, 0.0763321414227, 0.0679775525481, 0.0605382026668, 0.0552906772754, 0.053393511108, 0.0739172309381, 0.0595680613023, 0.0460835098095, 0.0353620136839, 0.0312643329067, 0.0691252856761, 0.0500301452396, 0.0320625529695, 0.0165043274227, 0.00986045001583, 0.0642515605719, 0.0407548193678, 0.0186153849175, -0.00146278671755, -0.0109561701507, 0.0598126311322, 0.0323386241814, 0.00622435185344, -0.0178819642463, -0.0303377240366], "PsiQModel_Lab": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0602502440555, 0.0561261666734, 0.043451228691, 0.0236408001234, 0.0, 0.0966505140769, 0.0947761413556, 0.0792258151143, 0.044919540751, 0.0, 0.114216909685, 0.115570705983, 0.103274932649, 0.0632243984501, 0.0, 0.124976371115, 0.127877730111, 0.118434219501, 0.0781238190327, 0.0, 0.132591636006, 0.13612555371, 0.128094538877, 0.089623037544, 0.0], "TorqueRippleModel_Lab": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "FeLossBackIronHy_MotorLAB": [0.196727537839, 0.196727537839, 0.196727537839, 0.196727537839, 0.196727537839, 0.323525981935, 0.267505229007, 0.202742548826, 0.146613272543, 0.121368536254, 0.507534286613, 0.41477192526, 0.266830238023, 0.131540290126, 0.0685629185636, 0.649648360395, 0.567064256156, 0.404244813725, 0.178334489473, 0.0380403490566, 0.738593554774, 0.67317344289, 0.541056645591, 0.274481320721, 0.0759612773855, 0.785984873327, 0.739451715237, 0.640485407686, 0.38526188494, 0.140939644213], "FeLossBackIronEd_MotorLAB": [0.000379124045658, 0.000379124045658, 0.000379124045658, 0.000379124045658, 0.000379124045658, 0.000607197386403, 0.000506066731905, 0.000386152405939, 0.000286728213861, 0.000245164894877, 0.00103348359848, 0.000836363694342, 0.000569202363951, 0.000312338237233, 0.000201102936379, 0.0013545171305, 0.00114512058289, 0.000809345201739, 0.000420512973159, 0.000233172364584, 0.0015691374296, 0.00138381756577, 0.00107418369282, 0.000582498077389, 0.000329216305125, 0.00172269514129, 0.00158320425878, 0.00129633582313, 0.000783006192103, 0.000459060944012], "FeLossToothHy_MotorLAB": [0.185412552243, 0.185412552243, 0.185412552243, 0.185412552243, 0.185412552243, 0.379115631661, 0.364289322081, 0.342049956623, 0.28841045513, 0.213277465728, 0.478478016276, 0.469333399324, 0.438679223867, 0.448201666152, 0.244290187976, 0.512785024242, 0.508480505048, 0.493498654718, 0.498180574212, 0.214211814093, 0.532741202253, 0.526764153942, 0.515350677609, 0.570318624799, 0.376962952345, 0.548118476396, 0.539355378576, 0.526658495085, 0.563132542256, 0.54761204866], "FeLossToothEd_MotorLAB": [0.000668873138897, 0.000668873138897, 0.000668873138897, 0.000668873138897, 0.000668873138897, 0.000820841435781, 0.000812762888633, 0.000838583840157, 0.000863054537206, 0.000854206201285, 0.0011829420831, 0.00107397049151, 0.00104543944777, 0.00121690076287, 0.00125101448227, 0.00151800219289, 0.00134902270132, 0.0012273852385, 0.00160623552182, 0.00181186405062, 0.00181343534685, 0.00165194354909, 0.00151230047755, 0.00189286115604, 0.00247961623565, 0.00201795493131, 0.00192851768946, 0.00178966741232, 0.00204775369452, 0.00309386460603], "FeLossRotorHy_MotorLAB": [0.000222171765457, 0.000222171765457, 0.000222171765457, 0.000222171765457, 0.000222171765457, 0.000506923751175, 0.000332091446786, 0.000261060931059, 0.000175625746203, 0.000173049583879, 0.000853029516709, 0.000279784214111, 0.000190333244912, 0.000214602058339, 0.000262389426499, 0.000399080681467, 0.000210824627608, 0.000125016317998, 0.000221224284766, 0.000706349987257, 0.000272667888211, 0.0002929621569, 0.000124113953653, 0.000320539109744, 0.00120738457134, 0.000512615154623, 0.000619078679594, 0.000271244321923, 0.000369468174263, 0.00144030017325], "FeLossRotorEd_MotorLAB": [3.30353507499e-07, 3.30353507499e-07, 3.30353507499e-07, 3.30353507499e-07, 3.30353507499e-07, 2.88613410829e-06, 1.88369501827e-06, 9.28466399633e-07, 4.82257044862e-07, 3.15024275647e-07, 1.78749065141e-06, 1.28235291029e-06, 6.39887229603e-07, 1.08619608246e-06, 9.34884478864e-07, 4.20202705857e-07, 3.19492608847e-07, 4.16630444096e-07, 2.28039418503e-06, 2.58908139689e-06, 3.38973467727e-07, 3.81899807657e-07, 5.48008095992e-07, 3.08807675076e-06, 5.60506835199e-06, 8.12681805712e-07, 8.05218944056e-07, 6.18854132514e-07, 6.33562588365e-06, 9.92946175491e-06], "FeLossRotorPoleHy_MotorLAB": [0.00522674027624, 0.00522674027624, 0.00522674027624, 0.00522674027624, 0.00522674027624, 0.0101867311086, 0.00857241201502, 0.00740518098735, 0.00575631256357, 0.00556989900347, 0.0151304266772, 0.0121009126506, 0.00907784293836, 0.00655407817757, 0.00589789522883, 0.0155155953358, 0.0124218478922, 0.0117124272, 0.00859917987867, 0.00862213627183, 0.0159750071332, 0.0140022618604, 0.0128861404546, 0.0105702358433, 0.011701772557, 0.0142994441299, 0.0140716715319, 0.013416517844, 0.0131107329323, 0.0147551017292], "FeLossRotorPoleEd_MotorLAB": [6.68453533697e-05, 6.68453533697e-05, 6.68453533697e-05, 6.68453533697e-05, 6.68453533697e-05, 0.000119233714639, 9.75138503054e-05, 7.46706304036e-05, 5.99110448235e-05, 5.31187673207e-05, 0.000187825463245, 0.000158132642187, 0.000117340113471, 8.40494033743e-05, 7.46840199751e-05, 0.000232857420553, 0.000208294370327, 0.000176901551561, 0.000138783019551, 0.000126265977775, 0.000260683482131, 0.000240471594752, 0.000231895097549, 0.000207985108723, 0.000205631284812, 0.000280887550993, 0.000262346554555, 0.000264881941407, 0.000284821554006, 0.000287087155144], "FeHysLossArray_MotorLAB": [0.387589002123, 0.387589002123, 0.387589002123, 0.387589002123, 0.387589002123, 0.713335268456, 0.640699054549, 0.552458747367, 0.440955665983, 0.34038895057, 1.00199575908, 0.896486021449, 0.714777638073, 0.586510636514, 0.319013391195, 1.17834806065, 1.08817743372, 0.909580911961, 0.685335467849, 0.261580649408, 1.28758243205, 1.21423282085, 1.06941757761, 0.855690720473, 0.465833386859, 1.34891540901, 1.29349784402, 1.18083166494, 0.961874628303, 0.704747094776], "FeEddyLossArray_MotorLAB": [0.00111517289143, 0.00111517289143, 0.00111517289143, 0.00111517289143, 0.00111517289143, 0.00155015867093, 0.00141822716586, 0.0013003353429, 0.00121017605294, 0.00115280488776, 0.00240603863548, 0.00206974918095, 0.00173262181242, 0.00161437459956, 0.0015277363231, 0.00310579694665, 0.00270275714715, 0.00221404862225, 0.00216781190871, 0.00217389147438, 0.00364359523205, 0.00327661460942, 0.00281892727601, 0.0026864324189, 0.00302006889394, 0.00402235030541, 0.00377487372174, 0.00335150403099, 0.00312191706651, 0.00384994216694], "MagLossArray_MotorLAB": [0.000573114279789, 0.000573114279789, 0.000573114279789, 0.000573114279789, 0.000573114279789, 0.00120216616567, 0.00148364616294, 0.00145150769075, 0.00100078918982, 0.000823725139978, 0.00180061522866, 0.00180248448899, 0.00266716350544, 0.0016777749922, 0.00135118081687, 0.00507071446861, 0.00449948060915, 0.0056880741092, 0.003093185807, 0.00166828483994, 0.0138822975515, 0.00818696146924, 0.00769071882756, 0.00726864496615, 0.00230662615003, 0.0385219715283, 0.0255680110063, 0.0100252164884, 0.0202010377965, 0.00940226565262], "WindageLossMap_NumSpeeds": 10, "WindageLossMap_NumTemps": 5, "WindageLossMap_Speeds": [0.0, 1111.111111111111, 2222.222222222222, 3333.333333333333, 4444.444444444444, 5555.555555555556, 6666.666666666666, 7777.777777777777, 8888.888888888889, 10000.0], "WindageLossMap_Temps": [0.0, 50.0, 100.0, 150.0, 200.0], "WindageLossMap_Losses": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "BearingLossMap_NumSpeeds": 10, "BearingLossMap_NumTemps": 5, "BearingLossMap_Speeds": [0.0, 1111.111111111111, 2222.222222222222, 3333.333333333333, 4444.444444444444, 5555.555555555556, 6666.666666666666, 7777.777777777777, 8888.888888888889, 10000.0], "BearingLossMap_Temps": [0.0, 50.0, 100.0, 150.0, 200.0], "BearingLossMap_Losses": [0.0, 0.0, 0.0, 0.0, 0.0, 2.77777777777778, 2.77777777777778, 2.77777777777778, 2.77777777777778, 2.77777777777778, 5.55555555555555, 5.55555555555555, 5.55555555555555, 5.55555555555555, 5.55555555555555, 8.33333333333335, 8.33333333333335, 8.33333333333335, 8.33333333333335, 8.33333333333335, 11.1111111111111, 11.1111111111111, 11.1111111111111, 11.1111111111111, 11.1111111111111, 13.8888888888889, 13.8888888888889, 13.8888888888889, 13.8888888888889, 13.8888888888889, 16.66666666666665, 16.66666666666665, 16.66666666666665, 16.66666666666665, 16.66666666666665, 19.44444444444445, 19.44444444444445, 19.44444444444445, 19.44444444444445, 19.44444444444445, 22.2222222222222, 22.2222222222222, 22.2222222222222, 22.2222222222222, 22.2222222222222, 25.0, 25.0, 25.0, 25.0, 25.0]} \ No newline at end of file diff --git a/tests/test_ocm.py b/tests/integration/test_ocm.py similarity index 95% rename from tests/test_ocm.py rename to tests/integration/test_ocm.py index 464bfe6a..1a56f9d3 100644 --- a/tests/test_ocm.py +++ b/tests/integration/test_ocm.py @@ -41,21 +41,18 @@ def token(): return token -@pytest.mark.integration def test_product_id(token): """Test product id from OCM.""" product_id = ocm.get_product_id(token) assert product_id == "SAAS000040" -@pytest.mark.integration def test_get_user_id(token): """Test user id from OCM.""" user_id = ocm.get_user_id(token) assert user_id == "95bb6bf9-0afd-4426-b736-7e1c8abd5a78" -@pytest.mark.integration def test_get_account_ids(token): """Test account ids from OCM.""" account_ids = ocm.get_account_ids(token) @@ -65,14 +62,12 @@ def test_get_account_ids(token): } -@pytest.mark.integration def test_get_account_id(token): """Test account ids from OCM.""" account_id = ocm.get_account_id(token) assert account_id == "2a566ece-938d-4658-bae5-ffa387ac0547" -@pytest.mark.integration def test_get_default_hpc(token): """Test default HPC from OCM.""" account_id = "2a566ece-938d-4658-bae5-ffa387ac0547" @@ -80,7 +75,6 @@ def test_get_default_hpc(token): assert hpc_id == "3ded64e3-5a83-24a8-b6e4-9fc30f97a654" -@pytest.mark.integration def test_get_project_ids(token): """Test projects from OCM.""" project_name = "New Project (with brackets)" @@ -91,7 +85,6 @@ def test_get_project_ids(token): assert "00932037-a633-464c-8d05-28353d9bfc49" in project_ids[project_name] -@pytest.mark.integration def test_create_new_project(token): """Test create new project from OCM.""" account_id = "2a566ece-938d-4658-bae5-ffa387ac0547" @@ -105,7 +98,6 @@ def test_create_new_project(token): assert seconds_ago < 10 -@pytest.mark.integration def test_create_new_design(token): """Test create new project from OCM.""" diff --git a/tests/integration/test_optislang_integration.py b/tests/integration/test_optislang_integration.py new file mode 100644 index 00000000..b1503f9f --- /dev/null +++ b/tests/integration/test_optislang_integration.py @@ -0,0 +1,431 @@ +# Copyright (C) 2023 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +from pathlib import Path +import re + +import httpx +import jwt + +# Optislang Integration Test +# A poor attempt at integration test for the optislang integration. +# Looks at conceptev/utils/api_helper.py to see pyconceptev usage within ConceptEV integration. +import pytest + +from ansys.conceptev.core import app, auth, exceptions + +DATA_DIR = Path(__file__).parent + + +@pytest.fixture +def msal_app(): + """Fixture to create a MSAL PublicClientApplication instance.""" + return auth.create_msal_app() + + +@pytest.fixture +def token(msal_app): + """Fixture to get a valid AnsysID token.""" + token = auth.get_ansyId_token(msal_app) + return token + + +@pytest.fixture +def client(token): + """Fixture to provide a client for testing.""" + with app.get_http_client(token) as client: + yield client + + +@pytest.fixture +def design_instance_id(): + """Fixture to provide a design instance ID for testing.""" + return "8cdea42d-fb8a-4499-a6f9-a188f2454afa" + + +@pytest.fixture +def client_with_design_instance(design_instance_id, token): + """Fixture to provide a client with a design instance ID for testing.""" + with app.get_http_client(token, design_instance_id) as client: + yield client + + +@pytest.fixture +def accounts(token): + """Fixture to get accounts.""" + accounts = app.get_account_ids(token) + return accounts + + +@pytest.fixture +def concept_data(client_with_design_instance, design_instance_id): + """Fixture to get concept data.""" + concept_data = app.get_concept(client_with_design_instance, design_instance_id) + return concept_data + + +@pytest.fixture +def account_id(accounts): + """Fixture to provide an account ID for testing.""" + return accounts[auth.settings.account_name] + + +@pytest.fixture +def hpc_id(token, account_id): + """Fixture to get the HPC ID.""" + hpc_id = app.get_default_hpc(token, account_id) + return hpc_id + + +@pytest.fixture +def job_info(client_with_design_instance, concept_data, account_id, hpc_id): + """Submit a job to the HPC.""" + job_info = app.create_submit_job( + client_with_design_instance, + concept_data, + account_id, + hpc_id, + ) + return job_info + + +@pytest.fixture +def read_results(client_with_design_instance, job_info): + """Read results from the job.""" + read_results = app.read_results( + client_with_design_instance, + job_info, + calculate_units=False, + filtered=True, + ) + return read_results + + +@pytest.fixture +def console_log(job_info, client_with_design_instance): + console_log = app.post(client_with_design_instance, "/jobs:error_file", data=job_info) + return console_log + + +@pytest.fixture +def project_name(): + """Project name fixture.""" + return "Integration Test from pyconceptev" + + +@pytest.fixture +def created_project(client, account_id, hpc_id, token, project_name): + created_project = app.create_new_project(client, account_id, hpc_id, f"{project_name}") + yield created_project + app.delete_project(created_project["projectId"], token) + + +@pytest.fixture +def project_id(created_project): + """Fixture to provide a project ID for testing.""" + return created_project["projectId"] + + +@pytest.fixture +def created_concept(client, project_id): + concept_data = app.create_new_concept( + client, + project_id, + title="ConceptEV Integration Test", + ) + return concept_data + + +@pytest.fixture +def account_ids(token): + """Fixture to get accounts.""" + account_ids = app.get_account_ids(token) + return account_ids + + +@pytest.fixture +def project_ids(project_name, created_project, account_id, token): + """Fixture to get project IDs.""" + project_ids = app.get_project_ids(re.escape(project_name), account_id, token) + return project_ids + + +def test_exceptions(): + """Example Exception Usage in api_helper""" + try: + raise exceptions.ResponseError("This is a test error") + except exceptions.ResponseError as e: + assert e.args[0].lower() + + +def test_msal_app(msal_app): + """Test that the MSAL PublicClientApplication is created.""" + assert isinstance(msal_app, auth.PublicClientApplication) + assert msal_app.client_id == auth.client_id + assert msal_app.authority.authorization_endpoint == auth.authority + "/oauth2/v2.0/authorize" + + +def test_auth_app(token): + """Test that the optislang integration works.""" + assert isinstance(token, str) + claims = jwt.decode(token, options={"verify_signature": False}) + # Step 1: Fetch JWKS + jwks = httpx.get(auth.settings.authority + "/discovery/v2.0/keys").json() + + # Step 2: Get headers from token to find correct kid + unverified_header = jwt.get_unverified_header(token) + kid = unverified_header["kid"] + key = next(k for k in jwks["keys"] if k["kid"] == kid) + public_key = jwt.algorithms.RSAAlgorithm.from_jwk(key) + algorithm = unverified_header["alg"] + jwt.decode(token, public_key, verify=True, algorithms=algorithm, options={"verify_aud": False}) + + +def test_client(client, token): + """Test that the client can make a request.""" + assert str(client.base_url).strip("/") == auth.settings.conceptev_url + assert client.headers["Authorization"] == f"{token}" + + +def test_client_design_instance(client_with_design_instance, token, design_instance_id): + """Test that the client can make a request with a design instance.""" + assert str(client_with_design_instance.base_url).strip("/") == auth.settings.conceptev_url + assert client_with_design_instance.headers["Authorization"] == f"{token}" + assert client_with_design_instance.params["design_instance_id"] == design_instance_id + # Additional checks can be added here for specific endpoints or data + + +def test_health(client): + """Test the health endpoint.""" + response = client.get("/health") + assert response.status_code == 200 + assert response.json()["name"] == "ConceptEV" + + +def test_authorised(client): + """Test the health endpoint.""" + response = client.get("/authenticated_user") + assert response.status_code == 200 + + +def test_get_concept(client, client_with_design_instance, design_instance_id, concept_data): + """Test getting a concept and getting ids.""" + concept = app.get(client, "/concepts", id=design_instance_id, params={"populated": False}) + concept["configurations"] = app.get( + client_with_design_instance, f"/concepts/{design_instance_id}/configurations" + ) + concept["components"] = app.get( + client_with_design_instance, f"/concepts/{design_instance_id}/components" + ) + concept["requirements"] = app.get( + client_with_design_instance, f"/concepts/{design_instance_id}/requirements" + ) + arch_id = concept["architecture_id"] + concept["architecture"] = app.get( + client_with_design_instance, + f"/architectures/{arch_id}", + params={"design_instance_id": design_instance_id}, + ) + assert concept == concept_data + + +def test_accounts(accounts, token): + """Test accounts endpoint.""" + assert isinstance(accounts, dict) + assert auth.settings.account_name in accounts + + +def test_hpc_endpoint(hpc_id): + assert isinstance(hpc_id, str) + assert len(hpc_id) > 0, "HPC ID should not be empty" + + +def test_submit_job(job_info): + assert isinstance(job_info, dict) + assert "job_id" in job_info + return job_info + + +def test_read_results(read_results): + """Test reading results from the job.""" + assert isinstance(read_results, list) + assert read_results[0]["feasible"] == False + assert len(read_results) > 0, "Results should not be empty" + + +def test_console_log(read_results, console_log): + """Test reading the console log.""" + assert isinstance(console_log, str) + assert len(console_log) > 0, "Console log should not be empty" + + +def test_create_project(created_project): + """Test creating a project.""" + assert isinstance(created_project, dict) + assert "projectId" in created_project + assert created_project["projectTitle"] == "Integration Test from pyconceptev" + + +def test_created_concept(created_concept, project_id): + """Test creating a concept.""" + assert isinstance(created_concept, dict) + assert created_concept["project_id"] == project_id + assert "design_instance_id" in created_concept + + +def test_get_accounts(account_ids, account_id): + """Test getting accounts.""" + assert isinstance(account_ids, dict) + assert auth.settings.account_name in account_ids + assert account_id in account_ids.values() + + +def test_project_ids(project_ids, project_id, project_name): + """Test project ids""" + assert isinstance(project_ids, dict) + assert project_name in project_ids + assert isinstance(project_ids[project_name], list) + assert project_id in project_ids[project_name] + + +@pytest.fixture +def transmission_loss_coefficients(client_with_design_instance): + """Fixture to provide transmission loss coefficients.""" + transmission = { + "component_type": "TransmissionLossCoefficients", + } + return app.post(client_with_design_instance, "/components", data=transmission) + + +@pytest.fixture +def aero(client_with_design_instance): + """Fixture to provide aero configuration.""" + aero = { + "config_type": "aero", + } + return app.post(client_with_design_instance, "/configurations", data=aero) + + +@pytest.fixture +def mass(client_with_design_instance): + """Fixture to provide mass configuration.""" + mass = { + "config_type": "mass", + } + return app.post(client_with_design_instance, "/configurations", data=mass) + + +@pytest.fixture +def wheel(client_with_design_instance): + """Fixture to provide wheel configuration.""" + wheel = { + "config_type": "wheel", + } + return app.post(client_with_design_instance, "/configurations", data=wheel) + + +@pytest.fixture +def requirement(client_with_design_instance, aero, mass, wheel): + requirement = { + "requirement_type": "static_acceleration", + "speed": 10, + "mass_id": mass["id"], + "aero_id": aero["id"], + "wheel_id": wheel["id"], + "state_of_charge": 0.75, + "acceleration": 0.5, + } + requirement = app.post(client_with_design_instance, "/requirements", data=requirement) + return requirement + + +@pytest.fixture +def motor_file(client_with_design_instance): + """Fixture to provide a motor configuration.""" + motor_filename = DATA_DIR / "e9.lab" + return app.post_component_file( + client_with_design_instance, motor_filename, component_file_type="motor_lab_file" + ) + + +@pytest.fixture +def motor(client_with_design_instance): + """Fixture to provide a battery configuration.""" + motor = { + "component_type": "MotorCTCP", + "name": "Test Motor", + "rated_power": 150000, + "stall_torque": 300, + "max_speed": 300, + "voltage": 400, + } + return app.post(client_with_design_instance, "/components", data=motor) + + +@pytest.fixture +def battery(client_with_design_instance): + """Fixture to provide a battery configuration.""" + battery = {"component_type": "BatteryFixedVoltages"} + return app.post(client_with_design_instance, "/components", data=battery) + + +@pytest.fixture +def architecture(client_with_design_instance, transmission_loss_coefficients, motor, battery): + architecture = { + "number_of_front_motors": 1, + "number_of_front_wheels": 2, + "number_of_rear_motors": 0, + "number_of_rear_wheels": 2, + "front_transmission_id": transmission_loss_coefficients["id"], + "front_motor_id": motor["id"], + "battery_id": battery["id"], + } + architecture = app.post(client_with_design_instance, "/architectures", data=architecture) + return architecture + + +def test_configuration(aero): + """Test creating an aero configuration.""" + assert aero + assert aero["config_type"] == "aero" + assert "id" in aero + + +def test_component(transmission_loss_coefficients): + assert transmission_loss_coefficients + assert "id" in transmission_loss_coefficients + + +def test_create_requirement(requirement): + assert requirement + assert "id" in requirement + + +def test_architecture(architecture): + """Test creating an architecture.""" + assert architecture + assert "id" in architecture + + +def test_create_from_file(motor_file): + assert isinstance(motor_file, list) + assert len(motor_file) == 2 diff --git a/tests/unit/config.toml b/tests/unit/config.toml new file mode 100644 index 00000000..5c524632 --- /dev/null +++ b/tests/unit/config.toml @@ -0,0 +1,9 @@ +OCM_URL = "https://dev.portal.onscale.com/api" +OCM_SOCKET_URL = "wss://sockets.dev.portal.onscale.com/socket" +CONCEPTEV_URL = "https://test-conceptev.awsansys3np.onscale.com/api" +client_id = "743c94e3-c72d-4ace-b9ee-ab5c3cbe6504" +authority = "https://a365dev.b2clogin.com/a365dev.onmicrosoft.com/b2c_1a_ansysid_signup_signin_test" +scope = "https://a365dev.onmicrosoft.com/AnsysID/Authentication" +conceptev_username = "conceptev_testing@ansys.com" +account_name = "ConceptEv Test Account" +job_timeout = 3600 \ No newline at end of file diff --git a/tests/test_app.py b/tests/unit/test_app.py similarity index 100% rename from tests/test_app.py rename to tests/unit/test_app.py diff --git a/tests/test_auth.py b/tests/unit/test_auth.py similarity index 100% rename from tests/test_auth.py rename to tests/unit/test_auth.py diff --git a/tests/test_metadata.py b/tests/unit/test_metadata.py similarity index 100% rename from tests/test_metadata.py rename to tests/unit/test_metadata.py diff --git a/tests/test_progress.py b/tests/unit/test_progress.py similarity index 100% rename from tests/test_progress.py rename to tests/unit/test_progress.py diff --git a/tests/test_settings.py b/tests/unit/test_settings.py similarity index 100% rename from tests/test_settings.py rename to tests/unit/test_settings.py