Skip to content

Commit

Permalink
Update unit testsUpdate unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ansnfernand committed Feb 4, 2025
1 parent 872f8f5 commit ae8af58
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/ansys/sherlock/core/types/analysis_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

"""Module containing types for the Analysis Service."""

from enum import Enum
from typing import Optional

from pydantic import BaseModel, ValidationInfo, field_validator
from pydantic import BaseModel, ConfigDict, ValidationInfo, field_validator

from ansys.sherlock.core.types.common_types import basic_str_validator

Expand Down Expand Up @@ -252,7 +253,7 @@ def _convert_to_grpc(
return request


class UpdatePTHFatiguePropsRequestAnalysisType:
class UpdatePTHFatiguePropsRequestAnalysisType(Enum):
"""Constants for qualification choices in the Update PTH Fatigue Properties request."""

__qualification_choices = (
Expand All @@ -268,9 +269,11 @@ class UpdatePTHFatiguePropsRequestAnalysisType:
"SUPPLIER"


class PTHFatigueAnalysis(BaseModel):
class PTHFatiguePropsAnalysis(BaseModel):
"""Contains the properties of a PTH fatigue analysis update request."""

model_config = ConfigDict(arbitrary_types_allowed=True)

cca_name: str
"""Name of the CCA."""
qualification_choices: Optional[UpdatePTHFatiguePropsRequestAnalysisType] = None
Expand Down Expand Up @@ -333,7 +336,7 @@ class UpdatePTHFatiguePropsRequest(BaseModel):

project: str
"""Name of the Sherlock project."""
pth_fatigue_analysis_properties: list[PTHFatigueAnalysis]
pth_fatigue_analysis_properties: list[PTHFatiguePropsAnalysis]
"""List of PTH fatigue analysis properties to update."""

@field_validator("project")
Expand Down
12 changes: 7 additions & 5 deletions tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
ComponentFailureMechanism,
ElementOrder,
ModelSource,
PTHFatiguePropsAnalysis,
RunAnalysisRequestAnalysisType,
RunStrainMapAnalysisRequestAnalysisType,
SemiconductorWearoutAnalysis,
Expand Down Expand Up @@ -2120,7 +2121,7 @@ def helper_test_update_semiconductor_wearout_props(analysis: Analysis):
def helper_test_update_PTH_fatigue_props(analysis: Analysis):
"""Test update PTH fatigue properties API."""
try:
PTHFatigueAnalysis(
PTHFatiguePropsAnalysis(
cca_name="",
pth_quality_factor="1.5",
pth_wall_thickness=0.1,
Expand Down Expand Up @@ -2159,10 +2160,10 @@ def helper_test_update_PTH_fatigue_props(analysis: Analysis):
assert isinstance(e, pydantic.ValidationError)
assert (
e.errors()[0]["msg"]
== "Input should be a valid dictionary or instance of PTHFatigueAnalysis"
== "Input should be a valid dictionary or instance of PTHFatiguePropsAnalysis"
)

pth_fatigue_analysis1 = PTHFatigueAnalysis(
pth_fatigue_analysis1 = PTHFatiguePropsAnalysis(
cca_name="Main Board",
qualification_choices=UpdatePTHFatiguePropsRequestAnalysisType.SUPPLIER,
pth_quality_factor="1.5",
Expand All @@ -2173,9 +2174,10 @@ def helper_test_update_PTH_fatigue_props(analysis: Analysis):
max_hole_size=1.0,
max_hole_size_units="mm",
)
pth_fatigue_analysis2 = PTHFatigueAnalysis(

pth_fatigue_analysis2 = PTHFatiguePropsAnalysis(
cca_name="Memory Card 1",
qualification_choices=UpdatePTHFatiguePropsRequestAnalysisType.Product,
qualification_choices=UpdatePTHFatiguePropsRequestAnalysisType.PRODUCT,
pth_quality_factor="2.0",
pth_wall_thickness=0.2,
pth_wall_thickness_units="mil",
Expand Down

0 comments on commit ae8af58

Please sign in to comment.