Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest #150

Merged
merged 8 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ Debug/
Release/

# for c2a user sample
Examples/src_aobc
Examples/src_aobc

# pytest cache
*.pyc

4 changes: 4 additions & 0 deletions src/src_user/Test/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
markers =
real
sils
3 changes: 3 additions & 0 deletions src/src_user/Test/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"c2a_src_rel_path": "/../../"
}
Empty file.
30 changes: 30 additions & 0 deletions src/src_user/Test/test/src_core/Applications/test_nop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys

import isslwings as wings
import pytest

ROOT_PATH = "../../../"
sys.path.append(os.path.dirname(__file__) + "/" + ROOT_PATH + "utils")
import c2a_enum_utils
import wings_utils

c2a_enum = c2a_enum_utils.get_c2a_enum()
ope = wings_utils.get_wings_operation()


@pytest.mark.real
@pytest.mark.sils
def test_nop():
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope,
c2a_enum.Cmd_CODE_NOP,
(),
c2a_enum.Tlm_CODE_AOBC_HK_GEN,
)

if __name__ == "__main__":
pass
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys

import isslwings as wings
import pytest

import time

ROOT_PATH = "../../../../../"
sys.path.append(os.path.dirname(__file__) + "/" + ROOT_PATH + "utils")
import c2a_enum_utils
import wings_utils

c2a_enum = c2a_enum_utils.get_c2a_enum()
ope = wings_utils.get_wings_operation()


@pytest.mark.real
@pytest.mark.sils
def test_target_quaternion():
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope,
c2a_enum.Cmd_CODE_APP_AOCS_MANAGER_SET_TARGET_QUATERNION,
(0.0, 0.0, 0.0, 1.0),
c2a_enum.Tlm_CODE_AOBC_HK_GEN,
)
time.sleep(1.0)
tlm_AOBC_HK_ALGO = ope.get_latest_tlm(c2a_enum.Tlm_CODE_AOBC_HK_ALGO)[0]
assert tlm_AOBC_HK_ALGO["AOBC_HK_ALGO.QUATERNION.TARGET_I2T_X"] == 0.0
assert tlm_AOBC_HK_ALGO["AOBC_HK_ALGO.QUATERNION.TARGET_I2T_Y"] == 0.0
assert tlm_AOBC_HK_ALGO["AOBC_HK_ALGO.QUATERNION.TARGET_I2T_Z"] == 0.0
assert tlm_AOBC_HK_ALGO["AOBC_HK_ALGO.QUATERNION.TARGET_I2T_W"] == 1.0

@pytest.mark.real
@pytest.mark.sils
def test_julian_day():
assert "SUC" == wings.util.send_rt_cmd_and_confirm(
ope,
c2a_enum.Cmd_CODE_APP_AOCS_MANAGER_SET_REFERENCE_TIME,
(2459933.0,),
c2a_enum.Tlm_CODE_AOBC_HK_GEN,
)
time.sleep(1.0)
tlm_AOBC_HK_ALGO = ope.get_latest_tlm(c2a_enum.Tlm_CODE_AOBC_HK_ALGO)[0]
assert tlm_AOBC_HK_ALGO["AOBC_HK_ALGO.TIME.REFERENCE_jday"] >= 2459933.0

if __name__ == "__main__":
pass
Empty file.
20 changes: 20 additions & 0 deletions src/src_user/Test/utils/c2a_enum_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import os
import c2aenum as c2a


def get_c2a_enum():
c2a_src_abs_path = os.environ.get("C2A_SRC_ABS_PATH")

# このifは環境変数が設定されているならsettings.jsonを無視したいという意図
if c2a_src_abs_path is None:
with open(os.path.dirname(__file__).replace("\\", "/") + "/../settings.json") as f:
json_dict = json.load(f)
c2a_src_abs_path = (
os.path.dirname(__file__).replace("\\", "/") + "/../" + json_dict["c2a_src_rel_path"]
)
chutaro marked this conversation as resolved.
Show resolved Hide resolved

return c2a.load_enum(c2a_src_abs_path, "utf-8")

17 changes: 17 additions & 0 deletions src/src_user/Test/utils/wings_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import isslwings as wings

obc_info = {
"name": "AOBC",
"hk_tlm_info": {
"tlm_name": "AOBC_HK_GEN",
"cmd_counter": "OBC.GS_CMD.COUNTER",
"cmd_last_exec_id": "OBC.GS_CMD.LAST_EXEC_ID",
"cmd_last_exec_sts": "OBC.GS_CMD.LAST_EXEC_STS",
},
}


def get_wings_operation():
return wings.Operation(obc_info=obc_info)