File: size_test.py

package info (click to toggle)
kiwi 10.2.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,664 kB
  • sloc: python: 69,179; sh: 4,228; xml: 3,383; ansic: 391; makefile: 353
file content (17 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from pytest import raises

from kiwi.utils.size import StringToSize

from kiwi.exceptions import KiwiSizeError


class TestStringToSize:
    def test_to_bytes(self):
        assert StringToSize.to_bytes('1m') == 1048576
        assert StringToSize.to_bytes('1M') == 1048576
        assert StringToSize.to_bytes('1g') == 1073741824
        assert StringToSize.to_bytes('1G') == 1073741824

    def test_to_bytes_wrong_format(self):
        with raises(KiwiSizeError):
            StringToSize.to_bytes('1mb')