Пример #1
0
    def test_import_export_with_childs(self):
        from pyinstruments import CurveDB
        c = CurveDB()
        s = pandas.Series([1,2,1])
        c.set_data(s)
        c.name = 'to_be_exported'
        c.save()
        
        c2 = CurveDB()
        s2 = pandas.Series([1,3,1])
        c2.set_data(s2)
        c2.name = 'to_be_exported_child'
        c2.move(c)
        
        queryset = CurveDB.objects.filter(id__in=[c.id, c2.id])
        from pyinstruments.curvestore.export import export_zip, import_zip
        export_zip(queryset, osp.dirname(__file__) + '/tests/temp_files/' +\
                    'test_export1.zip')
        c.delete()
        import_zip(osp.dirname(__file__) + '/tests/temp_files/' + \
                    'test_export1.zip')
        q = CurveDB.objects.filter_param('name', value='to_be_exported_child')

        self.assertEqual(q.count(), 1)
        self.assertLess((q[0].data - s2).abs().max(), 0.001)