Skip to content

Commit ce8688b

Browse files
committed
Updated TestSpecParsingDataType unit test module:
- Resolving linting errors
1 parent a05cb62 commit ce8688b

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/python_testing/TestSpecParsingDataType.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ def test_invalid_struct_field(self):
266266
parser = ClusterParser(et, self.cluster_id, self.cluster_name)
267267
cluster = parser.create_cluster()
268268
problems = parser.get_problems()
269+
270+
# Verify the valid field was parsed and the invalid one generated a problem
271+
asserts.assert_true("TestStruct" in cluster.structs, "TestStruct not found in parsed structs")
272+
struct = cluster.structs["TestStruct"]
273+
asserts.assert_equal(len(struct.components), 1, "Should only have one valid field")
274+
asserts.assert_true("1" in struct.components, "Valid field not found in struct components")
269275
asserts.assert_equal(len(problems), 1, "Should have one problem for invalid field")
270276
asserts.assert_true("Struct field in TestStruct with no id or name" in problems[0].problem,
271277
"Problem message doesn't match expected error")
@@ -378,18 +384,24 @@ def test_invalid_enum_item(self):
378384
parser = ClusterParser(et, self.cluster_id, self.cluster_name)
379385
cluster = parser.create_cluster()
380386
problems = parser.get_problems()
387+
388+
# Verify the valid item was parsed and the invalid one generated a problem
389+
asserts.assert_true("TestEnum" in cluster.enums, "TestEnum not found in parsed enums")
390+
enum = cluster.enums["TestEnum"]
391+
asserts.assert_equal(len(enum.components), 1, "Should only have one valid item")
392+
asserts.assert_true("0" in enum.components, "Valid item not found in enum components")
381393
asserts.assert_equal(len(problems), 1, "Should have one problem for invalid item")
382394
asserts.assert_true("Struct field in TestEnum with no id or name" in problems[0].problem,
383-
"Problem message doesn't match expected error")
395+
"Problem message doesn't match expected error")
384396

385397
def test_invalid_bitmap_field(self):
386-
"""Test handling of a bitmap with an invalid field (missing bit)"""
398+
"""Test handling of a bitmap with an invalid bitfield (missing bit)"""
387399
# Create a bitmap with one valid field and one invalid field (missing bit)
388400
bitmap_xml = """<bitmap name="TestBitmap">
389401
<bitfield bit="0" name="Bit0">
390402
<mandatoryConform/>
391403
</bitfield>
392-
<bitfield name="InvalidBitfield">
404+
<bitfield name="InvalidBit">
393405
<mandatoryConform/>
394406
</bitfield>
395407
</bitmap>"""
@@ -403,9 +415,15 @@ def test_invalid_bitmap_field(self):
403415
parser = ClusterParser(et, self.cluster_id, self.cluster_name)
404416
cluster = parser.create_cluster()
405417
problems = parser.get_problems()
418+
419+
# Verify the valid field was parsed and the invalid one generated a problem
420+
asserts.assert_true("TestBitmap" in cluster.bitmaps, "TestBitmap not found in parsed bitmaps")
421+
bitmap = cluster.bitmaps["TestBitmap"]
422+
asserts.assert_equal(len(bitmap.components), 1, "Should only have one valid field")
423+
asserts.assert_true("0" in bitmap.components, "Valid bitfield not found in bitmap components")
406424
asserts.assert_equal(len(problems), 1, "Should have one problem for invalid bitfield")
407425
asserts.assert_true("Struct field in TestBitmap with no id or name" in problems[0].problem,
408-
"Problem message doesn't match expected error")
426+
"Problem message doesn't match expected error")
409427

410428
def test_missing_name(self):
411429
"""Test handling of a data type with missing name attribute"""

0 commit comments

Comments
 (0)