def test_deserialize_minimal_old(self) -> None: # test for deprecated version during transition period, remove after final switch with self.assertWarnsRegex( DeprecationWarning, "deprecated", msg= "ForLoopPT does not issue warning for old serialization routines." ): body_str = 'dt' dt = DummyPulseTemplate(parameter_names={'i'}) def make_dt(ident: str): self.assertEqual(body_str, ident) return ident data = dict(body=body_str, loop_range=('A', 'B', 1), loop_index='i', identifier='meh') serializer = DummySerializer(deserialize_callback=make_dt) serializer.subelements['dt'] = dt flt = ForLoopPulseTemplate.deserialize(serializer, **data) self.assertEqual(flt.identifier, 'meh') self.assertEqual(flt.body, dt) self.assertEqual(flt.loop_index, 'i') self.assertEqual(flt.loop_range.to_tuple(), ('A', 'B', 1))
def test_deserialize_all_features_old(self) -> None: # test for deprecated version during transition period, remove after final switch with self.assertWarnsRegex(DeprecationWarning, "deprecated", msg="ForLoopPT does not issue warning for old serialization routines."): body_str = 'dt' dt = DummyPulseTemplate(parameter_names={'i'}) measurements = [('a', 0, 1), ('b', 1, 1)] parameter_constraints = ['foo < 3'] def make_dt(ident: str): self.assertEqual(body_str, ident) return ident data = dict(body=body_str, loop_range=('A', 'B', 1), loop_index='i', identifier='meh', measurements=measurements, parameter_constraints=parameter_constraints) serializer = DummySerializer(deserialize_callback=make_dt) serializer.subelements['dt'] = dt flt = ForLoopPulseTemplate.deserialize(serializer, **data) self.assertEqual(flt.identifier, 'meh') self.assertIs(flt.body, dt) self.assertEqual(flt.loop_index, 'i') self.assertEqual(flt.loop_range.to_tuple(), ('A', 'B', 1)) self.assertEqual(flt.measurement_declarations, measurements) self.assertEqual([str(c) for c in flt.parameter_constraints], parameter_constraints)