Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
rpakishore committed Mar 7, 2024
1 parent 7b186f3 commit fba0b65
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions documentation/Usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
"frames.get_points(frame_name='1') #Get points connected to frame\n",
"frames.delete(name='1') #Delete frame\n",
"\n",
"# Get frame properties\n",
"frames.Prop.rename(old_name=\"FSEC1\", new_name=\"MySection\") #Rename frame property\n",
"frames.Prop.total() #Total # of defined frame properties"
]
Expand Down
11 changes: 9 additions & 2 deletions src/ak_sap/Object/frame.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Literal

from ak_sap.utils import log
from ak_sap.utils.decorators import smooth_sap_do
from .helper import MasterObj
Expand All @@ -6,19 +8,24 @@ class Frame(MasterObj):
def __init__(self, mySapObject) -> None:
super().__init__(mySapObject=mySapObject, ElemObj=mySapObject.SapModel.FrameObj)

self.EditFrame = mySapObject.SapModel.EditFrame
self.Prop = Prop(mySapObject=mySapObject)

@smooth_sap_do
def get_section(self, frame_name: str) -> str:
self.check_element_legal(name=frame_name)
self.check_obj_legal(name=frame_name)
_ret = self.ElemObj.GetSection(frame_name)
return (_ret[0], _ret[-1]) # type: ignore

@smooth_sap_do
def get_points(self, frame_name: str) -> tuple[str]:
"""retrieves the names of the point objects at each end of a specified frame object."""
#self.check_element_legal(name=frame_name)
#self.check_obj_legal(name=frame_name)
return self.ElemObj.GetPoints(frame_name)

@smooth_sap_do
def divide_by_distance(self, frame_name: str, dist: float, Iend: bool=True, num_divisions: int=1):
return self.EditFrame.DivideAtDistance(frame_name, dist, Iend)

class Prop:
def __init__(self, mySapObject) -> None:
Expand Down
54 changes: 54 additions & 0 deletions src/tests/utils/test_decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from ak_sap.utils.decorators import smooth_sap_do


def test_smooth_sap_do():

@smooth_sap_do
def return_failed_list():
return [1,2,3,1]
assert return_failed_list() is None

@smooth_sap_do
def return_successful_list():
return [1,2,3,0]
assert return_successful_list() == [1,2,3]

@smooth_sap_do
def return_successful_tuple():
return [(1,2,3),0]
assert return_successful_tuple() == (1,2,3)

@smooth_sap_do
def return_failed_tuple():
return [(1,2,3),1]
assert return_failed_tuple() is None

@smooth_sap_do
def return_successful_str():
return ['alpha',0]
assert return_successful_str() == 'alpha'

@smooth_sap_do
def return_failed_str():
return ['alpha',1]
assert return_failed_str() is None

@smooth_sap_do
def return_successful_float():
return [3.14,0]
assert return_successful_float() == 3.14

@smooth_sap_do
def return_failed_float():
return [3.14,1]
assert return_failed_float() is None

@smooth_sap_do
def return_success():
return 0
assert return_success() == 0

@smooth_sap_do
def return_fail():
return 1
assert return_fail() is None

0 comments on commit fba0b65

Please sign in to comment.