示例#1
0
    def test_restore_invalid(self):
        """Make invalid 0.5.2 hierarchy, upgrade, and restore"""

        hierarchy = """
        loc1:
            .meta:
                group1.matrix:
                .group2:
                group3.list:
                    group4:
                    group5.wrongdict:
            loc2:
                .meta:
                    group6.dict:

        """

        hierarchy = yaml.load(hierarchy)

        root = os.path.join(self.root_path, 'root1')
        self.make_hierarchy(root, hierarchy)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 1)

        upgrade.walk(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 2)

        upgrade.restore(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 1)

        # Once restored, there shouldn't be a history left
        self.assertFalse(
            os.path.exists(
                os.path.join(root, upgrade.HISTORY_FILE)))
示例#2
0
    def test_restore_invalid(self):
        """Make invalid 0.5.2 hierarchy, upgrade, and restore"""

        hierarchy = """
        loc1:
            .meta:
                group1.matrix:
                .group2:
                group3.list:
                    group4:
                    group5.wrongdict:
            loc2:
                .meta:
                    group6.dict:

        """

        hierarchy = yaml.load(hierarchy)

        root = os.path.join(self.root_path, 'root1')
        self.make_hierarchy(root, hierarchy)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 1)

        upgrade.walk(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 2)

        upgrade.restore(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 1)

        # Once restored, there shouldn't be a history left
        self.assertFalse(
            os.path.exists(os.path.join(root, upgrade.HISTORY_FILE)))
示例#3
0
    def test_restore(self):
        """Make new 0.5.2 hierarchy, upgrade, and restore"""

        hierarchy = """
        loc1:
            .meta:
                group1:
                group2.dict:
                group3.dict:
                    group4:
                    group5.dict:
            loc2:
                .meta:
                    group6:

        """

        hierarchy = yaml.load(hierarchy)

        root = os.path.join(self.root_path, 'root0')
        self.make_hierarchy(root, hierarchy)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 3)

        upgrade.walk(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 6)

        upgrade.restore(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 3)
示例#4
0
    def test_restore(self):
        """Make new 0.5.2 hierarchy, upgrade, and restore"""

        hierarchy = """
        loc1:
            .meta:
                group1:
                group2.dict:
                group3.dict:
                    group4:
                    group5.dict:
            loc2:
                .meta:
                    group6:

        """

        hierarchy = yaml.load(hierarchy)

        root = os.path.join(self.root_path, 'root0')
        self.make_hierarchy(root, hierarchy)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 3)

        upgrade.walk(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 6)

        upgrade.restore(root)

        types = self.counts(root)
        self.assertEquals(types.get('total', 0), 11)
        self.assertEquals(types.get('dict', 0), 3)