Esempio n. 1
0
    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=
                "RepetitionPT does not issue warning for old serialization routines."
        ):
            serializer = DummySerializer(
                deserialize_callback=lambda x: x['name'])
            body = DummyPulseTemplate()
            data = dict(repetition_count='foo',
                        body=dict(name=str(id(body))),
                        identifier='foo',
                        parameter_constraints=['foo < 3'],
                        measurements=[('a', 0, 1), ('b', 1, 1)])
            # prepare dependencies for deserialization
            serializer.subelements[str(id(body))] = body

            # deserialize
            template = RepetitionPulseTemplate.deserialize(serializer, **data)

            # compare!
            self.assertIs(body, template.body)
            self.assertEqual('foo', template.repetition_count)
            self.assertEqual(template.parameter_constraints,
                             [ParameterConstraint('foo < 3')])
            self.assertEqual(template.measurement_declarations,
                             data['measurements'])
Esempio n. 2
0
 def test_deserialize_minimal_old(self) -> None:
     # test for deprecated version during transition period, remove after final switch
     with self.assertWarnsRegex(
             DeprecationWarning,
             "deprecated",
             msg=
             "RepetitionPT does not issue warning for old serialization routines."
     ):
         serializer = DummySerializer(
             deserialize_callback=lambda x: x['name'])
         body = DummyPulseTemplate()
         repetition_count = 3
         data = dict(repetition_count=repetition_count,
                     body=dict(name=str(id(body))),
                     identifier='foo')
         # prepare dependencies for deserialization
         serializer.subelements[str(id(body))] = body
         # deserialize
         template = RepetitionPulseTemplate.deserialize(serializer, **data)
         # compare!
         self.assertIs(body, template.body)
         self.assertEqual(repetition_count, template.repetition_count)