def test_calculate_G_label(self):
        '''Convert gigabyte labels to x * 10^9 bytes.'''
        size_str = '15G'
        drive_size = 20 * 10**9
        drive = BlockDevice(None, size=drive_size, available_size=drive_size)

        calc_size = ApplyNodeStorage.calculate_bytes(
            size_str=size_str, context=drive)

        assert calc_size == 15 * 10**9
    def test_calculate_G_label(self):
        '''Convert gigabyte labels to x * 10^9 bytes.'''
        size_str = '15G'
        drive_size = 20 * 1000 * 1000 * 1000
        drive = BlockDevice(None, size=drive_size, available_size=drive_size)

        calc_size = MaasTaskRunner.calculate_bytes(size_str=size_str,
                                                   context=drive)

        assert calc_size == 15 * 1000 * 1000 * 1000
    def test_calculate_TiB_label(self):
        '''Convert tebibyte labels to x * 2^40 bytes.'''
        size_str = '15TiB'
        drive_size = 20 * 2**40
        drive = BlockDevice(None, size=drive_size, available_size=drive_size)

        calc_size = ApplyNodeStorage.calculate_bytes(
            size_str=size_str, context=drive)

        assert calc_size == 15 * 2**40
    def test_calculate_TB_label(self):
        '''Convert terabyte labels to x * 10^12 bytes.'''
        size_str = '15TB'
        drive_size = 20 * 1000 * 1000 * 1000 * 1000
        drive = BlockDevice(None, size=drive_size, available_size=drive_size)

        calc_size = ApplyNodeStorage.calculate_bytes(size_str=size_str,
                                                     context=drive)

        assert calc_size == 15 * 1000 * 1000 * 1000 * 1000
    def test_calculate_percent_blockdev(self):
        '''Convert a percent of total blockdev space to explicit byte count.'''
        drive_size = 20 * 10**6  # 20 mb drive
        part_size = math.floor(.2 * drive_size)  # calculate 20% of drive size
        size_str = '20%'

        drive = BlockDevice(None, size=drive_size, available_size=drive_size)

        calc_size = ApplyNodeStorage.calculate_bytes(
            size_str=size_str, context=drive)

        assert calc_size == part_size