Esempio n. 1
0
    def test_get_serialization_data_minimal(self):

        dt = DummyPulseTemplate(parameter_names={'i'})
        flt = ForLoopPulseTemplate(body=dt, loop_index='i', loop_range=('A', 'B'))

        def check_dt(to_dictify) -> str:
            self.assertIs(to_dictify, dt)
            return 'dt'

        serializer = DummySerializer(serialize_callback=check_dt)

        data = flt.get_serialization_data(serializer)
        expected_data = dict(body='dt',
                             loop_range=('A', 'B', 1),
                             loop_index='i')
        self.assertEqual(data, expected_data)
Esempio n. 2
0
    def test_get_serialization_data_all_features(self):
        measurements = [('a', 0, 1), ('b', 1, 1)]
        parameter_constraints = ['foo < 3']

        dt = DummyPulseTemplate(parameter_names={'i'})
        flt = ForLoopPulseTemplate(body=dt, loop_index='i', loop_range=('A', 'B'),
                                   measurements=measurements, parameter_constraints=parameter_constraints)

        def check_dt(to_dictify) -> str:
            self.assertIs(to_dictify, dt)
            return 'dt'

        serializer = DummySerializer(serialize_callback=check_dt)

        data = flt.get_serialization_data(serializer)
        expected_data = dict(body='dt',
                             loop_range=('A', 'B', 1),
                             loop_index='i',
                             measurements=measurements,
                             parameter_constraints=parameter_constraints)
        self.assertEqual(data, expected_data)