<s> import mock <EOL> import unittest2 <EOL> from bareon . drivers . data import generic <EOL> class TestKsDisks ( unittest2 . TestCase ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TestKsDisks , self ) . __init__ ( * args , ** kwargs ) <EOL> self . driver = generic . GenericDataDriver ( None ) <EOL> self . driver . _partition_data = self . mock_part_data = mock . MagicMock ( ) <EOL> def test_no_partition_data ( self ) : <EOL> self . mock_part_data . return_value = [ ] <EOL> desired = [ ] <EOL> result = self . driver . _ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_no_partitions_valid_size ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:size>' : - <NUM_LIT:100> , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:size>' : <NUM_LIT:0> , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ ] <EOL> result = self . driver . _ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_no_partitions_valid_type ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:size>' : <NUM_LIT:100> , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:size>' : <NUM_LIT:200> , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ ] <EOL> result = self . driver . _ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_valid_data ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:size>' : <NUM_LIT:100> , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:size>' : <NUM_LIT:200> , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ { '<STR_LIT:size>' : <NUM_LIT:200> , '<STR_LIT:type>' : '<STR_LIT>' } ] <EOL> result = self . driver . _ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> class TestKsVgs ( unittest2 . TestCase ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TestKsVgs , self ) . __init__ ( * args , ** kwargs ) <EOL> self . driver = generic . GenericDataDriver ( None ) <EOL> self . driver . _partition_data = self . mock_part_data = mock . MagicMock ( ) <EOL> def test_no_partition_data ( self ) : <EOL> self . mock_part_data . return_value = [ ] <EOL> desired = [ ] <EOL> result = self . driver . _ks_vgs <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_no_partitions_valid_type ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ ] <EOL> result = self . driver . _ks_vgs <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_valid_data ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ { '<STR_LIT:type>' : '<STR_LIT>' } ] <EOL> result = self . driver . _ks_vgs <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> class TestSmallKsDisks ( unittest2 . TestCase ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TestSmallKsDisks , self ) . __init__ ( * args , ** kwargs ) <EOL> self . driver = generic . GenericDataDriver ( None ) <EOL> self . driver . _partition_data = self . mock_part_data = mock . MagicMock ( ) <EOL> def test_no_partition_data ( self ) : <EOL> self . mock_part_data . return_value = [ ] <EOL> desired = [ ] <EOL> result = self . driver . _small_ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_no_partitions_valid_size ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:size>' : <NUM_LIT:3> * <NUM_LIT> * <NUM_LIT> , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:size>' : <NUM_LIT:5> * <NUM_LIT> * <NUM_LIT> , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ ] <EOL> result = self . driver . _small_ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> def test_valid_data ( self ) : <EOL> self . mock_part_data . return_value = [ <EOL> { '<STR_LIT:size>' : <NUM_LIT:3> * <NUM_LIT> * <NUM_LIT> , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:size>' : <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> desired = [ { '<STR_LIT:size>' : <NUM_LIT:1> * <NUM_LIT> * <NUM_LIT> , '<STR_LIT:type>' : '<STR_LIT>' } ] <EOL> result = self . driver . _small_ks_disks <EOL> self . assertEqual ( result , desired ) <EOL> self . mock_part_data . assert_called_once_with ( ) <EOL> class TestGetLabel ( unittest2 . TestCase ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( TestGetLabel , self ) . __init__ ( * args , ** kwargs ) <EOL> self . driver = generic . GenericDataDriver ( None ) <EOL> def test_no_label ( self ) : <EOL> label = None <EOL> desired = '<STR_LIT>' <EOL> result = self . driver . _getlabel ( label ) <EOL> self . assertEqual ( result , desired ) <EOL> def test_long_label ( self ) : <EOL> label = '<STR_LIT:l>' * <NUM_LIT:100> <EOL> desired = '<STR_LIT>' . format ( '<STR_LIT:l>' * <NUM_LIT:12> ) <EOL> result = self . driver . _getlabel ( label ) <EOL> self . assertEqual ( result , desired ) <EOL> def test_valid_label ( self ) : <EOL> label = '<STR_LIT:label>' <EOL> desired = '<STR_LIT>' . format ( label ) <EOL> result = self . driver . _getlabel ( label ) <EOL> self . assertEqual ( result , desired ) </s>
