Skip to content

Commit

Permalink
Merge pull request #150 from ut-issl/feature/add-pytest
Browse files Browse the repository at this point in the history
Add pytest
  • Loading branch information
200km authored Aug 7, 2023
2 parents 605722a + 8029499 commit 292b243
Show file tree
Hide file tree
Showing 25 changed files with 119 additions and 1 deletion.
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
Empty file added src/src_user/Test/test/.gitkeep
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.
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.
Empty file.
Empty file.
12 changes: 12 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,12 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import os
import c2aenum as c2a


def get_c2a_enum():
c2a_src_abs_path = os.path.dirname(__file__).replace("\\", "/") + "/../../.."

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)

0 comments on commit 292b243

Please sign in to comment.