libasterix 0.36.1__tar.gz → 0.36.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libasterix
3
- Version: 0.36.1
3
+ Version: 0.36.2
4
4
  Summary: Asterix data processing library
5
5
  Author-email: Zoran Bošnjak <zoran.bosnjak@via.si>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "libasterix"
3
- version = "0.36.1"
3
+ version = "0.36.2"
4
4
  authors = [
5
5
  { name="Zoran Bošnjak", email="zoran.bosnjak@via.si" },
6
6
  ]
@@ -576,7 +576,9 @@ class Spare(ItemBase):
576
576
  return cls._parse(bs)
577
577
 
578
578
  @classmethod
579
- def create(cls, arg: int) -> 'Spare':
579
+ def create(cls, arg: Union['Spare', int]) -> 'Spare':
580
+ if isinstance(arg, Spare):
581
+ return arg
580
582
  bs = Bits.from_uinteger(arg, cls.cv_bit_offset8, cls.cv_bit_size)
581
583
  return cls(bs)
582
584
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libasterix
3
- Version: 0.36.1
3
+ Version: 0.36.2
4
4
  Summary: Asterix data processing library
5
5
  Author-email: Zoran Bošnjak <zoran.bosnjak@via.si>
6
6
  License-Expression: MIT
@@ -7,6 +7,7 @@ from typing import *
7
7
  import pytest
8
8
 
9
9
  from . generated import *
10
+ from . import sample_records
10
11
 
11
12
 
12
13
  def test_create() -> None:
@@ -1163,6 +1164,30 @@ def test_empty() -> None:
1163
1164
  rec2 = Cat_000_1_0.cv_record.create({})
1164
1165
  assert rec2.is_empty()
1165
1166
 
1167
+ def _test_roundtrip(num_records: int) -> None:
1168
+ """For each specification and edition, create a few records,
1169
+ encode, decode, expect the same result."""
1170
+
1171
+ def check(Spec: AstCat, r: Record) -> None:
1172
+ records = list([r]*num_records)
1173
+ bs = b''.join([r.unparse().to_bytes() for r in records])
1174
+ if m_name is None:
1175
+ result = Spec.cv_uap.parse(Bits.from_bytes(bs)) # type: ignore
1176
+ else:
1177
+ result = Spec.cv_uap.parse(m_name, Bits.from_bytes(bs)) # type: ignore
1178
+ assert not isinstance(result, ValueError)
1179
+ bs2 = b''.join([r.unparse().to_bytes() for r in result])
1180
+ assert bs2 == bs
1181
+
1182
+ for lst in manifest['CATS'].values(): # type: ignore
1183
+ for Spec in lst:
1184
+ for (m_name, r1, r2) in sample_records(Spec):
1185
+ check(Spec, r1)
1186
+ check(Spec, r2)
1187
+
1188
+ def test_roundtrip() -> None:
1189
+ _test_roundtrip(5)
1190
+
1166
1191
  # python specific tests
1167
1192
 
1168
1193
 
File without changes
File without changes
File without changes