forked from IMAP-Science-Operations-Center/imap_processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request IMAP-Science-Operations-Center#184 from bourque/te…
…st-ccsds-header Test CCSDS header across all instrument packet definitions
- Loading branch information
Showing
7 changed files
with
79 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""Tests aspects of the decommutation process that is generic to all instruments""" | ||
|
||
import pytest | ||
|
||
from imap_processing import imap_module_directory | ||
|
||
# Scrape the repo for all packet definition XML files | ||
xtce_document_list = imap_module_directory.glob("*/packet_definitions/*.xml") | ||
|
||
|
||
@pytest.fixture(params=xtce_document_list, scope="session") | ||
def xtce_document(request): | ||
if "idex" in str(request.param): | ||
pytest.xfail( | ||
"Packet Definition does not include properly formatted CCSDS Header" | ||
) | ||
else: | ||
return request.param | ||
|
||
|
||
def test_ccsds_header(xtce_document): | ||
"""Test if the XTCE document contains the proper CCSDS header information""" | ||
|
||
# Define what is expected in the XTCE document | ||
header_keys = [ | ||
("VERSION", "UINT3"), | ||
("TYPE", "UINT1"), | ||
("SEC_HDR_FLG", "UINT1"), | ||
("PKT_APID", "UINT11"), | ||
("SEQ_FLGS", "UINT2"), | ||
("SRC_SEQ_CTR", "UINT14"), | ||
("PKT_LEN", "UINT16"), | ||
] | ||
header_entry_list = ( | ||
"<xtce:EntryList>" | ||
' <xtce:ParameterRefEntry parameterRef="VERSION" />' | ||
' <xtce:ParameterRefEntry parameterRef="TYPE" />' | ||
' <xtce:ParameterRefEntry parameterRef="SEC_HDR_FLG" />' | ||
' <xtce:ParameterRefEntry parameterRef="PKT_APID" />' | ||
' <xtce:ParameterRefEntry parameterRef="SEQ_FLGS" />' | ||
' <xtce:ParameterRefEntry parameterRef="SRC_SEQ_CTR" />' | ||
' <xtce:ParameterRefEntry parameterRef="PKT_LEN" />' | ||
"</xtce:EntryList>" | ||
) | ||
|
||
# Read in the XTCE document | ||
with open(xtce_document) as f: | ||
document = f.read() | ||
|
||
# Check that each header key is defined as a Parameter | ||
for key in header_keys: | ||
assert ( | ||
f'<xtce:Parameter name="{key[0]}" parameterTypeRef="{key[1]}"' in document | ||
or f'<xtce:Parameter name="{key[0]}" parameterTypeRef="{key[1].lower()}"' | ||
in document | ||
) | ||
|
||
# Check that the header is defined as a SequenceContainer in the XTCE file | ||
# First remove discrepancies in whitespace, tabs, and newlines | ||
header_entry_list = ( | ||
header_entry_list.replace(" ", "").replace("\t", "").replace("\n", "") | ||
) | ||
document = document.replace(" ", "").replace("\t", "").replace("\n", "") | ||
assert header_entry_list in document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters