Exemplo n.º 1
0
    def test_include_package(self):
        from testpkg.module import TopData
        from testpkg.subpkg1.module import MidData1
        from testpkg.subpkg2.module import MidData2
        from testpkg.subpkg1.subsubpkg.module import BottomData

        expected_dict = dict()
        for cls in [TopData, MidData1, MidData2, BottomData]:
            cls.ensure_table()
            data = [cls(name='Name' + str(i)) for i in range(7)]
            for d in data:
                d.save()
            expected_dict[backup_name(cls)] = data

        self.backup.add_package("testpkg")

        self.assertEquals(4, len(self.backup.classes))

        bucketname, keyname = self.backup.run_backup()
        backups = extract_backup(bucketname, keyname)

        for cls in [TopData, MidData1, MidData2, BottomData]:
            expected = expected_dict[backup_name(cls)]
            self.assertObjListsEq(expected, extract_one(backups, cls))
    def test_include_package(self):
        from testpkg.module import TopData
        from testpkg.subpkg1.module import MidData1
        from testpkg.subpkg2.module import MidData2
        from testpkg.subpkg1.subsubpkg.module import BottomData

        expected_dict = dict()
        for cls in [TopData, MidData1, MidData2, BottomData]:
            cls.ensure_table()
            data = [cls(name='Name'+str(i)) for i in range(7)]
            for d in data:
                d.save()
            expected_dict[backup_name(cls)] = data

        self.backup.add_package("testpkg")

        self.assertEquals(4, len(self.backup.classes))

        bucketname, keyname = self.backup.run_backup()
        backups = extract_backup(bucketname, keyname)

        for cls in [TopData, MidData1, MidData2, BottomData]:
            expected = expected_dict[backup_name(cls)]
            self.assertObjListsEq(expected, extract_one(backups, cls))
Exemplo n.º 3
0
def extract_one(backup_dict, cls):
    """Given the dict from extract_backup and a class, return a list of objects
    from the backup"""
    name = backup_name(cls) + '.json'  # Don't forget file extension
    return [cls.from_data(i) for i in backup_dict[name]]
def extract_one(backup_dict, cls):
    """Given the dict from extract_backup and a class, return a list of objects
    from the backup"""
    name = backup_name(cls) + '.json'  # Don't forget file extension
    return [cls.from_data(i) for i in backup_dict[name]]