fprime/Svc/FileManager/test/int/test_cmd_fileManager.py
chuynh4duarte 8b9ac2197d
Add reusable InT test scripts (#3923)
* add deployment function

* update file to use config json file

* remove unuse function

* fix typos

* fixed spelling

* update to use get_mnemonic

* rm shellcmd from fileManager and add health & systemResources testcase

* check memory usage and number of CPUs

* remove Ref.PingReceiver and fixed typos

* fixed spelling fileDownlink,health,systemResources and add config.json file

* Update config.json

* replace ActiveLogger to EventManager

* Updated config.json use lowercase CdhCore and FileHandling(fileDownlink,fileManager,prmDb) and ComCcsds(cmdSeq) etc

* update test_cmd_version to compare version of telemetry channel vs. evr version

* extend max_delay to work with Raspberry pi

* rename config.json to int_config.json

* delete Ref/config.json new file name int_config.json

* add time.sleep between AppendFile cmd to work with rasberry Pi

* fix int_config.json and add new Int DpMgr, DpWriter and DpCatalog

* add comments to confirm /tmp/1MiB.txt and /tmp/test_seq.seq exist before execute script

* add send uplink files

* Rename config.json, fix spelling

* python formatting

---------

Co-authored-by: Cindy T Huynh <chuynh@jpl.nasa.gov>
Co-authored-by: M Starch <LeStarch@googlemail.com>
Co-authored-by: Thomas Boyer-Chammard <49786685+thomas-bc@users.noreply.github.com>
Co-authored-by: Kevin F. Ortega <kevin.f.ortega@jpl.nasa.gov>
2025-08-29 10:29:39 -07:00

87 lines
2.8 KiB
Python

"""test_cmd_FileManager.py:
Test the command FileManager with basic integration tests.
fileManager.CreateDirectory
fileManager.ShellCommand # Don't use ShellCommand
fileManager.FileSize
fileManager.MoveFile
fileManager.AppendFile
fileManager.RemoveFile
fileManager.RemoveDirectory
"""
import time
def test_send_fileManager_command(fprime_test_api):
"""Test that commands may be sent
Tests command send, dispatch, and receipt using send_and_assert command with a pair of fileManager commands.
"""
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "CreateDirectory",
["/tmp/file"],
max_delay=10,
)
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "CreateDirectory",
["/tmp/file2"],
max_delay=10,
)
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "FileSize",
["/tmp/1MiB.txt"],
max_delay=50,
)
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "MoveFile",
["/tmp/1MiB.txt", "/tmp/file/1MiB.txt"],
max_delay=50,
)
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "FileSize",
["/tmp/file/1MiB.txt"],
max_delay=50,
)
# Use small file to AppendFile to work with RaspberryPi
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "AppendFile",
["/tmp/test_seq.seq", "/tmp/file/test_seq.seq"],
)
time.sleep(10)
# put back
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "MoveFile",
["/tmp/file/1MiB.txt", "/tmp/1MiB.txt"],
max_delay=50,
)
# fail bc directory is not empty (pytest script will stop if use send_and_assert_cmd. Use send_command to avoid stop) No max_delay (expected warning_hi)
fprime_test_api.send_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "RemoveDirectory",
["/tmp/file"],
)
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "RemoveDirectory",
["/tmp/file2"],
max_delay=10,
)
# Cleanup directory
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "RemoveFile",
["/tmp/file/test_seq.seq", True],
max_delay=5,
)
fprime_test_api.send_and_assert_command(
fprime_test_api.get_mnemonic("Svc.FileManager") + "." + "RemoveDirectory",
["/tmp/file"],
max_delay=5,
)