Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

import unittest 

import mock 

 

import SR 

import vhdutil 

import xs_errors 

import testlib 

 

class TestVhdUtil(unittest.TestCase): 

 

    def test_validate_and_round_min_size(self): 

        size = vhdutil.validate_and_round_vhd_size(2 * 1024 * 1024) 

 

        self.assertTrue(size == 2 * 1024 * 1024) 

 

    def test_validate_and_round_max_size(self): 

        size = vhdutil.validate_and_round_vhd_size(vhdutil.MAX_VHD_SIZE) 

 

        self.assertTrue(size == vhdutil.MAX_VHD_SIZE) 

 

    def test_validate_and_round_odd_size_up_to_next_boundary(self): 

        size = vhdutil.validate_and_round_vhd_size(vhdutil.MAX_VHD_SIZE - 1) 

 

        self.assertTrue(size == vhdutil.MAX_VHD_SIZE) 

 

    @testlib.with_context 

    def test_validate_and_round_negative(self, context): 

        context.setup_error_codes() 

        with self.assertRaises(SR.SROSError): 

            vhdutil.validate_and_round_vhd_size(-1) 

 

    @testlib.with_context 

    def test_validate_and_round_too_large(self, context): 

        context.setup_error_codes() 

        with self.assertRaises(SR.SROSError): 

            vhdutil.validate_and_round_vhd_size(vhdutil.MAX_VHD_SIZE + 1)