Skip to content

Commit 6c8b43d

Browse files
authored
Add field to TableFieldInfo (#117)
* feat: add `has_mode` field to `TableFieldInfo` * test: test_get_fields_type_table updated to check has_mode * doc: add `has_mode` to `TableFieldInfo` docstring
1 parent 75f4f57 commit 6c8b43d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/pandablocks/commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ def _table(
701701
int(max_length),
702702
fields_dict,
703703
row_words,
704+
has_mode=version >= (4, 0),
704705
)
705706

706707
return field_name, field_info

src/pandablocks/responses.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,16 @@ class TableFieldDetails:
148148

149149
@dataclass
150150
class TableFieldInfo(FieldInfo):
151-
"""Extended `FieldInfo` for fields with type "table"""
151+
"""Extended `FieldInfo` for fields with type "table"
152+
153+
Attribute "has_mode" is set to True when created from `GetFieldInfo`
154+
with API version >= (4, 0)
155+
"""
152156

153157
max_length: int
154158
fields: dict[str, TableFieldDetails]
155159
row_words: int
160+
has_mode: bool = False
156161

157162

158163
@dataclass

tests/test_pandablocks.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,18 @@ def test_get_fields_parameterized_type(
993993
]
994994

995995

996-
def test_get_fields_type_table():
996+
@pytest.mark.parametrize(
997+
"api_version,expected_has_mode",
998+
[
999+
((3, 9), False),
1000+
((4, 0), True),
1001+
((4, 1), True),
1002+
],
1003+
)
1004+
def test_get_fields_type_table(api_version, expected_has_mode):
9971005
"""Test for table field type, including descriptions and retrieving enum labels"""
9981006
conn = ControlConnection()
1007+
conn.set_api(api_version)
9991008
cmd = GetFieldInfo("SEQ")
10001009
assert conn.send(cmd) == b"SEQ.*?\n"
10011010

@@ -1062,6 +1071,7 @@ def test_get_fields_type_table():
10621071
labels=None,
10631072
),
10641073
},
1074+
has_mode=expected_has_mode,
10651075
)
10661076
},
10671077
)

0 commit comments

Comments
 (0)