Skip to content

Commit

Permalink
test(Server): Automated server test
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Sep 29, 2023
1 parent e899d67 commit 1751a31
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
12 changes: 6 additions & 6 deletions tests/function_description_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

def compare_function_description(fd1, fd2):
# compare names
fd1_name = fd1["name"] if type(fd1) is dict else fd1.name
fd2_name = fd2["name"] if type(fd2) is dict else fd2.name
fd1_name = fd1["name"] if isinstance(fd1, dict) else fd1.name
fd2_name = fd2["name"] if isinstance(fd2, dict) else fd2.name
# print(fd1_name, len(fd1_name))
# print(fd2_name, len(fd2_name))
assert fd1_name == fd2_name
# compare parameters
fd1_parameters = fd1["parameters"] if type(fd1) is dict else fd1.parameters
fd2_parameters = fd2["parameters"] if type(fd2) is dict else fd2.parameters
fd1_parameters = fd1["parameters"] if isinstance(fd1, dict) else fd1.parameters
fd2_parameters = fd2["parameters"] if isinstance(fd2, dict) else fd2.parameters
# print(len(fd1_parameters))
# print(len(fd2_parameters))
assert len(fd1_parameters) == len(fd2_parameters)
Expand All @@ -54,12 +54,12 @@ def compare_function_description(fd1, fd2):
# compare fields
fd1_fields = (
param1["type_description"]["fields"]
if type(param1["type_description"]) is dict
if isinstance(param1["type_description"], dict)
else param1["type_description"].fields
)
fd2_fields = (
param2["type_description"]["fields"]
if type(param2["type_description"]) is dict
if isinstance(param2["type_description"], dict)
else param2["type_description"].fields
)
assert len(fd1_fields) == len(fd2_fields)
Expand Down
90 changes: 45 additions & 45 deletions tests/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def test_basic_datatypes():
in_value = is_input[attr]
out_value = res[attr]
if attr == "ZFLTP":
assert type(out_value) is float
assert isinstance(out_value, float)
else:
assert type(out_value) is Decimal
assert isinstance(out_value, Decimal)
if type(in_value) != type(out_value):
assert str(in_value) == str(out_value)
else:
Expand Down Expand Up @@ -167,12 +167,12 @@ def test_min_max_positive():
IV_COUNT=0,
)["ES_OUTPUT"]

assert type(output["ZFLTP_MIN"]) is float
assert type(output["ZFLTP_MAX"]) is float
assert type(output["ZDECF16_MIN"]) is Decimal
assert type(output["ZDECF16_MAX"]) is Decimal
assert type(output["ZDECF34_MAX"]) is Decimal
assert type(output["ZDECF16_MIN"]) is Decimal
assert isinstance(output["ZFLTP_MIN"], float)
assert isinstance(output["ZFLTP_MAX"], float)
assert isinstance(output["ZDECF16_MIN"], Decimal)
assert isinstance(output["ZDECF16_MAX"], Decimal)
assert isinstance(output["ZDECF34_MAX"], Decimal)
assert isinstance(output["ZDECF16_MIN"], Decimal)

assert float(IS_INPUT["ZFLTP_MIN"]) == output["ZFLTP_MIN"]
assert float(IS_INPUT["ZFLTP_MAX"]) == output["ZFLTP_MAX"]
Expand Down Expand Up @@ -200,12 +200,12 @@ def test_min_max_negative():
IV_COUNT=0,
)["ES_OUTPUT"]

assert type(output["ZFLTP_MIN"]) is float
assert type(output["ZFLTP_MAX"]) is float
assert type(output["ZDECF16_MIN"]) is Decimal
assert type(output["ZDECF16_MAX"]) is Decimal
assert type(output["ZDECF16_MIN"]) is Decimal
assert type(output["ZDECF34_MAX"]) is Decimal
assert isinstance(output["ZFLTP_MIN"], float)
assert isinstance(output["ZFLTP_MAX"], float)
assert isinstance(output["ZDECF16_MIN"], Decimal)
assert isinstance(output["ZDECF16_MAX"], Decimal)
assert isinstance(output["ZDECF16_MIN"], Decimal)
assert isinstance(output["ZDECF34_MAX"], Decimal)

assert float(IS_INPUT["ZFLTP_MIN"]) == output["ZFLTP_MIN"]
assert float(IS_INPUT["ZFLTP_MAX"]) == output["ZFLTP_MAX"]
Expand Down Expand Up @@ -281,25 +281,25 @@ def test_bcd_floats_accept_strings():
IS_INPUT=IS_INPUT,
IV_COUNT=0,
)["ES_OUTPUT"]
assert type(output["ZFLTP"]) is float
assert isinstance(output["ZFLTP"], float)
assert float(IS_INPUT["ZFLTP"]) == output["ZFLTP"]

assert type(output["ZDEC"]) is Decimal
assert isinstance(output["ZDEC"], Decimal)
assert IS_INPUT["ZDEC"] == str(output["ZDEC"])

assert type(output["ZDECF16_MIN"]) is Decimal
assert isinstance(output["ZDECF16_MIN"], Decimal)
assert IS_INPUT["ZDECF16_MIN"] == str(output["ZDECF16_MIN"])

assert type(output["ZDECF34_MIN"]) is Decimal
assert isinstance(output["ZDECF34_MIN"], Decimal)
assert IS_INPUT["ZDECF34_MIN"] == str(output["ZDECF34_MIN"])

assert type(output["ZCURR"]) is Decimal
assert isinstance(output["ZCURR"], Decimal)
assert IS_INPUT["ZCURR"] == str(output["ZCURR"])

assert type(output["ZQUAN"]) is Decimal
assert isinstance(output["ZQUAN"], Decimal)
assert IS_INPUT["ZQUAN"] == str(output["ZQUAN"])

assert type(output["ZQUAN_SIGN"]) is Decimal
assert isinstance(output["ZQUAN_SIGN"], Decimal)
assert IS_INPUT["ZQUAN_SIGN"] == str(output["ZQUAN_SIGN"])


Expand All @@ -323,25 +323,25 @@ def test_bcd_floats_accept_strings_radix_comma():
IS_INPUT=IS_INPUT,
IV_COUNT=0,
)["ES_OUTPUT"]
assert type(output["ZFLTP"]) is float
assert isinstance(output["ZFLTP"], float)
assert float(IS_INPUT["ZFLTP"]) == output["ZFLTP"]

assert type(output["ZDEC"]) is Decimal
assert isinstance(output["ZDEC"], Decimal)
assert IS_INPUT["ZDEC"] == str(output["ZDEC"])

assert type(output["ZDECF16_MIN"]) is Decimal
assert isinstance(output["ZDECF16_MIN"], Decimal)
assert IS_INPUT["ZDECF16_MIN"] == str(output["ZDECF16_MIN"])

assert type(output["ZDECF34_MIN"]) is Decimal
assert isinstance(output["ZDECF34_MIN"], Decimal)
assert IS_INPUT["ZDECF34_MIN"] == str(output["ZDECF34_MIN"])

assert type(output["ZCURR"]) is Decimal
assert isinstance(output["ZCURR"], Decimal)
assert IS_INPUT["ZCURR"] == str(output["ZCURR"])

assert type(output["ZQUAN"]) is Decimal
assert isinstance(output["ZQUAN"], Decimal)
assert IS_INPUT["ZQUAN"] == str(output["ZQUAN"])

assert type(output["ZQUAN_SIGN"]) is Decimal
assert isinstance(output["ZQUAN_SIGN"], Decimal)
assert IS_INPUT["ZQUAN_SIGN"] == str(output["ZQUAN_SIGN"])
# locale.setlocale(locale.LC_ALL, "")

Expand All @@ -365,25 +365,25 @@ def test_bcd_floats_accept_decimals():
IS_INPUT=IS_INPUT,
IV_COUNT=0,
)["ES_OUTPUT"]
assert type(output["ZFLTP"]) is float
assert isinstance(output["ZFLTP"], float)
assert IS_INPUT["ZFLTP"] == Decimal(str(output["ZFLTP"]))

assert type(output["ZDEC"]) is Decimal
assert isinstance(output["ZDEC"], Decimal)
assert IS_INPUT["ZDEC"] == Decimal(str(output["ZDEC"]))

assert type(output["ZDECF16_MIN"]) is Decimal
assert isinstance(output["ZDECF16_MIN"], Decimal)
assert IS_INPUT["ZDECF16_MIN"] == Decimal(str(output["ZDECF16_MIN"]))

assert type(output["ZDECF34_MIN"]) is Decimal
assert isinstance(output["ZDECF34_MIN"], Decimal)
assert IS_INPUT["ZDECF34_MIN"] == Decimal(str(output["ZDECF34_MIN"]))

assert type(output["ZCURR"]) is Decimal
assert isinstance(output["ZCURR"], Decimal)
assert IS_INPUT["ZCURR"] == Decimal(str(output["ZCURR"]))

assert type(output["ZQUAN"]) is Decimal
assert isinstance(output["ZQUAN"], Decimal)
assert IS_INPUT["ZQUAN"] == Decimal(str(output["ZQUAN"]))

assert type(output["ZQUAN_SIGN"]) is Decimal
assert isinstance(output["ZQUAN_SIGN"], Decimal)
assert IS_INPUT["ZQUAN_SIGN"] == Decimal(str(output["ZQUAN_SIGN"]))


Expand All @@ -401,8 +401,8 @@ def test_raw_types_accept_bytes():
)["ES_OUTPUT"]
assert output["ZRAW"] == ZRAW + DIFF
assert output["ZRAWSTRING"] == ZRAW
assert type(output["ZRAW"]) is bytes
assert type(output["ZRAWSTRING"]) is bytes
assert isinstance(output["ZRAW"], bytes)
assert isinstance(output["ZRAWSTRING"], bytes)


def test_raw_types_accept_bytearray():
Expand Down Expand Up @@ -479,8 +479,8 @@ def test_date_accepts_string():
IMPORTSTRUCT=IMPORTSTRUCT,
RFCTABLE=IMPORTTABLE,
)
assert type(output["ECHOSTRUCT"]["RFCDATE"]) is str
assert type(output["RFCTABLE"][0]["RFCDATE"]) is str
assert isinstance(output["ECHOSTRUCT"]["RFCDATE"], str)
assert isinstance(output["RFCTABLE"][0]["RFCDATE"], str)
assert output["ECHOSTRUCT"]["RFCDATE"] == TEST_DATE
assert output["RFCTABLE"][0]["RFCDATE"] == TEST_DATE

Expand All @@ -494,8 +494,8 @@ def test_date_accepts_date():
IMPORTSTRUCT=IMPORTSTRUCT,
RFCTABLE=IMPORTTABLE,
)
assert type(output["ECHOSTRUCT"]["RFCDATE"]) is str
assert type(output["RFCTABLE"][0]["RFCDATE"]) is str
assert isinstance(output["ECHOSTRUCT"]["RFCDATE"], str)
assert isinstance(output["RFCTABLE"][0]["RFCDATE"], str)
assert output["ECHOSTRUCT"]["RFCDATE"] == python_to_ABAP_date(TEST_DATE)
assert output["RFCTABLE"][0]["RFCDATE"] == python_to_ABAP_date(TEST_DATE)

Expand All @@ -509,8 +509,8 @@ def test_time_accepts_string():
IMPORTSTRUCT=IMPORTSTRUCT,
RFCTABLE=IMPORTTABLE,
)
assert type(output["ECHOSTRUCT"]["RFCTIME"]) is str
assert type(output["RFCTABLE"][0]["RFCTIME"]) is str
assert isinstance(output["ECHOSTRUCT"]["RFCTIME"], str)
assert isinstance(output["RFCTABLE"][0]["RFCTIME"], str)
assert output["ECHOSTRUCT"]["RFCTIME"] == TEST_TIME
assert output["RFCTABLE"][0]["RFCTIME"] == TEST_TIME

Expand All @@ -524,8 +524,8 @@ def test_time_accepts_time():
IMPORTSTRUCT=IMPORTSTRUCT,
RFCTABLE=IMPORTTABLE,
)
assert type(output["ECHOSTRUCT"]["RFCTIME"]) is str
assert type(output["RFCTABLE"][0]["RFCTIME"]) is str
assert isinstance(output["ECHOSTRUCT"]["RFCTIME"], str)
assert isinstance(output["RFCTABLE"][0]["RFCTIME"], str)
assert output["ECHOSTRUCT"]["RFCTIME"] == python_to_ABAP_time(TEST_TIME)
assert output["RFCTABLE"][0]["RFCTIME"] == python_to_ABAP_time(TEST_TIME)

Expand Down

0 comments on commit 1751a31

Please sign in to comment.