Ejemplo n.º 1
0
def test_convert_to_unit__time():
    # 1 minute is 60 seconds
    assert_equal(convert_to_unit('1m', SECOND), 60)
    assert_equal(convert_to_unit('1 m', SECOND), 60)
Ejemplo n.º 2
0
def test_convert_to_unit__bad_input():
    # number part must be an int
    with assert_raises(ValueError) as context:
        convert_to_unit('12.5 GB', BLOCK_8KB)
    assert_contains(context.exception.message, '12.5 GB')
Ejemplo n.º 3
0
def test_convert_to_unit__mixed_units():
    with assert_raises(ValueError) as context:
        convert_to_unit('1kB', MS)
    assert_contains(context.exception.message, '1kB')
    assert_contains(context.exception.message, 'TimeInMilliseconds')
Ejemplo n.º 4
0
def test_convert_to_unit__bytes():
    # 12 GB is 12 * 1024 * 1024 / 8 "8kB blocks" = 1572864 "8kB blocks"
    assert_equal(convert_to_unit('12GB', BLOCK_8KB), 1572864)
    assert_equal(convert_to_unit('12 GB', BLOCK_8KB), 1572864)
def test_convert_to_unit__time():
    # 1 minute is 60 seconds
    assert_equal(convert_to_unit('1m', SECOND), 60)
    assert_equal(convert_to_unit('1 m', SECOND), 60)
def test_convert_to_unit__mixed_units():
    with assert_raises(ValueError) as context:
        convert_to_unit('1kB', MS)
    assert_contains(context.exception.message, '1kB')
    assert_contains(context.exception.message, 'TimeInMilliseconds')
def test_convert_to_unit__bad_input():
    # number part must be an int
    with assert_raises(ValueError) as context:
        convert_to_unit('12.5 GB', BLOCK_8KB)
    assert_contains(context.exception.message, '12.5 GB')
def test_convert_to_unit__bytes():
    # 12 GB is 12 * 1024 * 1024 / 8 "8kB blocks" = 1572864 "8kB blocks"
    assert_equal(convert_to_unit('12GB', BLOCK_8KB), 1572864)
    assert_equal(convert_to_unit('12 GB', BLOCK_8KB), 1572864)