示例#1
0
    def test_move_down(self):

        region_levels = [
            [
                ['aa', 'ee', BlockDesc(size=1)],
                ['hh', 'hz', BlockDesc(size=2)],
                ['pp', 'zz', BlockDesc(size=3)],
                ['zz', None, BlockDesc(size=4)]
            ],
            [
                ['cf', 'cz', BlockDesc(size=5)],
                ['mm', 'oo', BlockDesc(size=6)],
                ['oo', 'qq', BlockDesc(size=7)]
            ],
            [
                ['aa', 'bb', BlockDesc(size=8)],
                ['cc', 'cd', BlockDesc(size=9)],
                ['ee', 'ff', BlockDesc(size=10)]
            ],
            [
                ['aa', 'ab', BlockDesc(size=11)],
                ['az', 'bb', BlockDesc(size=12)],
                ['za', None, BlockDesc(size=13)]
            ],
            [
                ['d', 'fz', BlockDesc(size=14)]
            ],
        ]

        excepted_region_levels = [
            [
                ['aa', 'ee', BlockDesc(size=1)],
                ['ee', 'ff', BlockDesc(size=10)],
                ['hh', 'hz', BlockDesc(size=2)],
                ['mm', 'oo', BlockDesc(size=6)],
                ['pp', 'zz', BlockDesc(size=3)],
                ['zz', None, BlockDesc(size=4)]
            ],
            [
                ['aa', 'bb', BlockDesc(size=8)],
                ['cc', 'cd', BlockDesc(size=9)],
                ['cf', 'cz', BlockDesc(size=5)],
                ['d', 'fz', BlockDesc(size=14)],
                ['oo', 'qq', BlockDesc(size=7)],
                ['za', None, BlockDesc(size=13)]
            ],
            [
                ['aa', 'ab', BlockDesc(size=11)],
                ['az', 'bb', BlockDesc(size=12)]
            ],
        ]

        excepted_moved_blocks = [
            (1, 0, ['mm', 'oo', BlockDesc(size=6)]),
            (2, 1, ['aa', 'bb', BlockDesc(size=8)]),
            (2, 1, ['cc', 'cd', BlockDesc(size=9)]),
            (2, 0, ['ee', 'ff', BlockDesc(size=10)]),
            (3, 2, ['aa', 'ab', BlockDesc(size=11)]),
            (3, 2, ['az', 'bb', BlockDesc(size=12)]),
            (3, 1, ['za', None, BlockDesc(size=13)]),
            (4, 1, ['d',  'fz', BlockDesc(size=14)]),
        ]

        region = Region(levels=region_levels)
        moved_blocks = region.move_down()

        self.assertEqual(excepted_moved_blocks, moved_blocks)
        self.assertEqual(excepted_region_levels, region['levels'])

        region_levels = [
            [['aa', 'ee', BlockDesc(size=1)], ['ee', 'ff', BlockDesc(size=10)], ['hh', 'hz', BlockDesc(size=2)]],
            [['aa', 'yy', BlockDesc(size=8)]]
        ]

        region = Region(levels=region_levels)
        moved_blocks = region.move_down()

        self.assertEqual([], moved_blocks)
        self.assertEqual(region_levels, region['levels'])
    def test_move_down(self):

        region_levels = [
            [
                ['aa', 'ee', BlockDesc(size=1)],
                ['hh', 'hz', BlockDesc(size=2)],
                ['pp', 'zz', BlockDesc(size=3)],
                ['zz', None, BlockDesc(size=4)]
            ],
            [
                ['cf', 'cz', BlockDesc(size=5)],
                ['mm', 'oo', BlockDesc(size=6)],
                ['oo', 'qq', BlockDesc(size=7)]
            ],
            [
                ['aa', 'bb', BlockDesc(size=8)],
                ['cc', 'cd', BlockDesc(size=9)],
                ['ee', 'ff', BlockDesc(size=10)]
            ],
            [
                ['aa', 'ab', BlockDesc(size=11)],
                ['az', 'bb', BlockDesc(size=12)],
                ['za', None, BlockDesc(size=13)]
            ],
            [
                ['d', 'fz', BlockDesc(size=14)]
            ],
        ]

        excepted_region_levels = [
            [
                ['aa', 'ee', BlockDesc(size=1)],
                ['ee', 'ff', BlockDesc(size=10)],
                ['hh', 'hz', BlockDesc(size=2)],
                ['mm', 'oo', BlockDesc(size=6)],
                ['pp', 'zz', BlockDesc(size=3)],
                ['zz', None, BlockDesc(size=4)]
            ],
            [
                ['aa', 'bb', BlockDesc(size=8)],
                ['cc', 'cd', BlockDesc(size=9)],
                ['cf', 'cz', BlockDesc(size=5)],
                ['d', 'fz', BlockDesc(size=14)],
                ['oo', 'qq', BlockDesc(size=7)],
                ['za', None, BlockDesc(size=13)]
            ],
            [
                ['aa', 'ab', BlockDesc(size=11)],
                ['az', 'bb', BlockDesc(size=12)]
            ],
        ]

        excepted_moved_blocks = [
            (1, 0, ['mm', 'oo', BlockDesc(size=6)]),
            (2, 1, ['aa', 'bb', BlockDesc(size=8)]),
            (2, 1, ['cc', 'cd', BlockDesc(size=9)]),
            (2, 0, ['ee', 'ff', BlockDesc(size=10)]),
            (3, 2, ['aa', 'ab', BlockDesc(size=11)]),
            (3, 2, ['az', 'bb', BlockDesc(size=12)]),
            (3, 1, ['za', None, BlockDesc(size=13)]),
            (4, 1, ['d',  'fz', BlockDesc(size=14)]),
        ]

        region = Region(levels=region_levels)
        moved_blocks = region.move_down()

        self.assertEqual(excepted_moved_blocks, moved_blocks)
        self.assertEqual(excepted_region_levels, region['levels'])

        region_levels = [
            [['aa', 'ee', BlockDesc(size=1)], ['ee', 'ff', BlockDesc(size=10)], ['hh', 'hz', BlockDesc(size=2)]],
            [['aa', 'yy', BlockDesc(size=8)]]
        ]

        region = Region(levels=region_levels)
        moved_blocks = region.move_down()

        self.assertEqual([], moved_blocks)
        self.assertEqual(region_levels, region['levels'])
示例#3
0
文件: test_region.py 项目: bsc-s2/ops
    def test_move_down(self):

        region_levels = [
            [
                ['aa', 'ee', tbid1],
                ['hh', 'hz', tbid2],
                ['pp', 'zz', tbid3],
                ['zz', None, tbid4]
            ],
            [
                ['cf', 'cz', tbid5],
                ['mm', 'oo', tbid6],
                ['oo', 'qq', tbid7]
            ],
            [
                ['aa', 'bb', tbid8],
                ['cc', 'cd', tbid9],
                ['ee', 'ff', tbid10]
            ],
            [
                ['aa', 'ab', tbid11],
                ['az', 'bb', tbid12],
                ['za', None, tbid13]
            ],
            [
                ['d', 'fz', tbid14]
            ],
        ]

        excepted_region_levels = [
            [
                ['aa', 'ee', tbid1],
                ['ee', 'ff', tbid10],
                ['hh', 'hz', tbid2],
                ['mm', 'oo', tbid6],
                ['pp', 'zz', tbid3],
                ['zz', None, tbid4]
            ],
            [
                ['aa', 'bb', tbid8],
                ['cc', 'cd', tbid9],
                ['cf', 'cz', tbid5],
                ['d', 'fz', tbid14],
                ['oo', 'qq', tbid7],
                ['za', None, tbid13]
            ],
            [
                ['aa', 'ab', tbid11],
                ['az', 'bb', tbid12]
            ],
        ]

        excepted_moved_blocks = [
            (1, 0, ['mm', 'oo', tbid6]),
            (2, 1, ['aa', 'bb', tbid8]),
            (2, 1, ['cc', 'cd', tbid9]),
            (2, 0, ['ee', 'ff', tbid10]),
            (3, 2, ['aa', 'ab', tbid11]),
            (3, 2, ['az', 'bb', tbid12]),
            (3, 1, ['za', None, tbid13]),
            (4, 1, ['d',  'fz', tbid14]),
        ]

        region = Region(levels=region_levels)
        moved_blocks = region.move_down()

        self.assertEqual(excepted_moved_blocks, moved_blocks)
        self.assertEqual(excepted_region_levels, region['levels'])

        region_levels = [
            [
                ['aa', 'ee', tbid1],
                ['ee', 'ff', tbid10],
                ['hh', 'hz', tbid2],
            ],
            [['aa', 'yy', tbid8]]
        ]

        region = Region(levels=region_levels)
        moved_blocks = region.move_down()

        self.assertEqual([], moved_blocks)
        self.assertEqual(region_levels, region['levels'])