@@ -84,25 +84,56 @@ def test_creates_unknown_cmd_tlm_packets(self):
8484
8585 # context "with all telemetry keywords" do
8686 # before(:all) do
87- # top level keywords
87+ # Top level keywords (don't require current packet or item)
8888 top_keywords = [
8989 "SELECT_COMMAND" ,
9090 "SELECT_TELEMETRY" ,
9191 "LIMITS_GROUP" ,
9292 "LIMITS_GROUP_ITEM" ,
9393 ]
94- # Keywords that require a current packet from TELEMETRY keyword
94+ # Keywords that require a current TELEMETRY packet (telemetry-specific ITEM keywords)
9595 tlm_keywords = [
9696 "SELECT_ITEM" ,
97+ "DELETE_ITEM" ,
9798 "ITEM" ,
9899 "ID_ITEM" ,
99100 "ARRAY_ITEM" ,
100101 "APPEND_ITEM" ,
101102 "APPEND_ID_ITEM" ,
102103 "APPEND_ARRAY_ITEM" ,
104+ "ALLOW_SHORT" ,
103105 "PROCESSOR" ,
104106 "META" ,
105107 ]
108+ # Keywords that require a current COMMAND packet (command-specific PARAMETER keywords)
109+ cmd_keywords = [
110+ "SELECT_PARAMETER" ,
111+ "DELETE_PARAMETER" ,
112+ "PARAMETER" ,
113+ "ID_PARAMETER" ,
114+ "ARRAY_PARAMETER" ,
115+ "APPEND_PARAMETER" ,
116+ "APPEND_ID_PARAMETER" ,
117+ "APPEND_ARRAY_PARAMETER" ,
118+ ]
119+ # Keywords that apply to both COMMAND and TELEMETRY packets
120+ packet_keywords = [
121+ "HAZARDOUS" ,
122+ "RESTRICTED" ,
123+ "DISABLE_MESSAGES" ,
124+ "HIDDEN" ,
125+ "DISABLED" ,
126+ "VIRTUAL" ,
127+ "ACCESSOR" ,
128+ "VALIDATOR" ,
129+ "TEMPLATE" ,
130+ "TEMPLATE_FILE" ,
131+ "RESPONSE" ,
132+ "ERROR_RESPONSE" ,
133+ "SCREEN" ,
134+ "RELATED_ITEM" ,
135+ "IGNORE_OVERLAP" ,
136+ ]
106137 # Keywords that require both a current packet and current item
107138 item_keywords = [
108139 "STATE" ,
@@ -161,6 +192,11 @@ def test_complains_if_there_are_not_enough_parameters(self):
161192 tf .close ()
162193
163194 for keyword in TestPacketConfig .tlm_keywords :
195+ # Skip keywords that don't require parameters or are tested elsewhere
196+ ignore_tlm = ["PROCESSOR" , "META" , "ALLOW_SHORT" ]
197+ if keyword in ignore_tlm :
198+ continue
199+
164200 tf = tempfile .NamedTemporaryFile (mode = "w" )
165201 tf .write ('TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Packet"\n ' )
166202 tf .write (keyword )
@@ -188,28 +224,24 @@ def test_complains_if_there_are_not_enough_parameters(self):
188224 tf .close ()
189225
190226 def test_builds_the_id_value_hash (self ):
191- for keyword in TestPacketConfig .tlm_keywords :
192- if keyword == "PROCESSOR" or keyword == "META" :
193- continue
194-
195- tf = tempfile .NamedTemporaryFile (mode = "w" )
196- tf .write ('TELEMETRY tgt1 pkt1 BIG_ENDIAN "Packet"\n ' )
197- tf .write ('ID_ITEM myitem 0 8 UINT 13 "Test Item id=1"\n ' )
198- tf .write ('APPEND_ID_ITEM myitem 8 UINT 114 "Test Item id=1"\n ' )
199- tf .write ('COMMAND tgt1 pkt1 BIG_ENDIAN "Packet"\n ' )
200- tf .write ('ID_PARAMETER myitem 0 8 UINT 12 12 12 "Test Item id=1"\n ' )
201- tf .write ('APPEND_ID_PARAMETER myitem 8 UINT 115 115 115 "Test Item id=1"\n ' )
202- tf .seek (0 )
203- self .pc .process_file (tf .name , "TGT1" )
204- expected_tlm_hash = {}
205- expected_tlm_hash ["TGT1" ] = {}
206- expected_tlm_hash ["TGT1" ]["[13, 114]" ] = self .pc .telemetry ["TGT1" ]["PKT1" ]
207- expected_cmd_hash = {}
208- expected_cmd_hash ["TGT1" ] = {}
209- expected_cmd_hash ["TGT1" ]["[12, 115]" ] = self .pc .commands ["TGT1" ]["PKT1" ]
210- self .assertEqual (self .pc .tlm_id_value_hash , expected_tlm_hash )
211- self .assertEqual (self .pc .cmd_id_value_hash , expected_cmd_hash )
212- tf .close ()
227+ tf = tempfile .NamedTemporaryFile (mode = "w" )
228+ tf .write ('TELEMETRY tgt1 pkt1 BIG_ENDIAN "Packet"\n ' )
229+ tf .write ('ID_ITEM myitem 0 8 UINT 13 "Test Item id=1"\n ' )
230+ tf .write ('APPEND_ID_ITEM myitem 8 UINT 114 "Test Item id=1"\n ' )
231+ tf .write ('COMMAND tgt1 pkt1 BIG_ENDIAN "Packet"\n ' )
232+ tf .write ('ID_PARAMETER myitem 0 8 UINT 12 12 12 "Test Item id=1"\n ' )
233+ tf .write ('APPEND_ID_PARAMETER myitem 8 UINT 115 115 115 "Test Item id=1"\n ' )
234+ tf .seek (0 )
235+ self .pc .process_file (tf .name , "TGT1" )
236+ expected_tlm_hash = {}
237+ expected_tlm_hash ["TGT1" ] = {}
238+ expected_tlm_hash ["TGT1" ]["[13, 114]" ] = self .pc .telemetry ["TGT1" ]["PKT1" ]
239+ expected_cmd_hash = {}
240+ expected_cmd_hash ["TGT1" ] = {}
241+ expected_cmd_hash ["TGT1" ]["[12, 115]" ] = self .pc .commands ["TGT1" ]["PKT1" ]
242+ self .assertEqual (self .pc .tlm_id_value_hash , expected_tlm_hash )
243+ self .assertEqual (self .pc .cmd_id_value_hash , expected_cmd_hash )
244+ tf .close ()
213245
214246 def test_complains_if_there_are_too_many_parameters (self ):
215247 for keyword in TestPacketConfig .top_keywords :
@@ -250,6 +282,10 @@ def test_complains_if_there_are_too_many_parameters(self):
250282 case "SELECT_ITEM" :
251283 tf .write ("ITEM myitem 0 8 UINT\n " )
252284 tf .write ("SELECT_ITEM myitem extra\n " )
285+ case "DELETE_ITEM" :
286+ tf .write ("DELETE_ITEM myitem extra\n " )
287+ case "ALLOW_SHORT" :
288+ tf .write ("ALLOW_SHORT extra\n " )
253289 tf .seek (0 )
254290 with self .assertRaisesRegex (ConfigParser .Error , f"Too many parameters for { keyword } " ):
255291 self .pc .process_file (tf .name , "TGT1" )
@@ -863,6 +899,17 @@ def test_hazardous_takes_a_description(self):
863899 )
864900 tf .close ()
865901
902+ def test_marks_the_packet_as_restricted (self ):
903+ tf = tempfile .NamedTemporaryFile (mode = "w" )
904+ tf .write ('COMMAND tgt2 pkt1 LITTLE_ENDIAN "Description"\n ' )
905+ tf .write ("RESTRICTED\n " )
906+ tf .write ('COMMAND tgt2 pkt2 LITTLE_ENDIAN "Description"\n ' )
907+ tf .seek (0 )
908+ self .pc .process_file (tf .name , "SYSTEM" )
909+ self .assertTrue (self .pc .commands ["TGT2" ]["PKT1" ].restricted )
910+ self .assertFalse (self .pc .commands ["TGT2" ]["PKT2" ].restricted )
911+ tf .close ()
912+
866913 def test_complains_about_missing_conversion_file (self ):
867914 self .pc = PacketConfig ()
868915
0 commit comments