<s> import unittest <EOL> from yaml import safe_load <EOL> from swiftlm . rings . hlm_model import InputModel <EOL> from swiftlm . rings . ring_model import DeviceInfo <EOL> from tests . data . ring_padawan import padawan_input_model , padawan_net_hosts , padawan_swf_rng_consumes , expected_lv_devices <EOL> lvm_disk_model = '''<STR_LIT>''' <EOL> device_groups_disk_model = '''<STR_LIT>''' <EOL> class TestHlmModel ( unittest . TestCase ) : <EOL> def test_iter_volume_groups ( self ) : <EOL> input_model = InputModel ( config = safe_load ( padawan_input_model ) , <EOL> hosts_fd = padawan_net_hosts , <EOL> consumes = padawan_swf_rng_consumes ) <EOL> lv_devices = [ ] <EOL> lv_expected = [ ] <EOL> for lv_device in input_model . _iter_volume_groups ( ) : <EOL> lv_devices . append ( DeviceInfo ( lv_device ) ) <EOL> self . assertEqual ( len ( lv_devices ) , <NUM_LIT:3> ) <EOL> for lv_device in expected_lv_devices : <EOL> lv_expected . append ( DeviceInfo ( lv_device ) ) <EOL> lv_expected = sorted ( lv_expected , None , DeviceInfo . sortkey ) <EOL> lv_devices = sorted ( lv_devices , None , DeviceInfo . sortkey ) <EOL> for i in range ( <NUM_LIT:0> , len ( lv_expected ) ) : <EOL> self . assertEqual ( sorted ( lv_expected [ i ] . keys ( ) ) , <EOL> sorted ( lv_devices [ i ] . keys ( ) ) ) <EOL> for key in lv_expected [ i ] . keys ( ) : <EOL> self . assertEqual ( lv_expected [ i ] . get ( key ) , <EOL> lv_devices [ i ] . get ( key ) ) <EOL> class TestLvm ( unittest . TestCase ) : <EOL> def test_lvm_numbering ( self ) : <EOL> input_model = InputModel ( config = safe_load ( lvm_disk_model ) , <EOL> hosts_fd = padawan_net_hosts , <EOL> consumes = padawan_swf_rng_consumes ) <EOL> lv_devices = [ ] <EOL> lv_info = set ( ) <EOL> for lv_device in input_model . _iter_volume_groups ( ) : <EOL> lv_devices . append ( DeviceInfo ( lv_device ) ) <EOL> lv_info . add ( ( lv_device . server_name , lv_device . ring_name , <EOL> lv_device . swift_drive_name ) ) <EOL> self . assertEqual ( len ( lv_devices ) , <NUM_LIT:11> ) <EOL> lv_expected = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] <EOL> for lv in set ( lv_expected ) : <EOL> self . assertTrue ( lv in lv_info , '<STR_LIT>' % ( <EOL> lv , lv_info ) ) <EOL> lv_expected . remove ( lv ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( lv_expected ) , '<STR_LIT>' % lv_expected ) <EOL> class TestDev ( unittest . TestCase ) : <EOL> def test_dev_numbering ( self ) : <EOL> input_model = InputModel ( config = safe_load ( device_groups_disk_model ) , <EOL> hosts_fd = padawan_net_hosts , <EOL> consumes = padawan_swf_rng_consumes ) <EOL> dev_devices = [ ] <EOL> dev_info = set ( ) <EOL> for dev_device in input_model . _iter_device_groups ( ) : <EOL> dev_devices . append ( DeviceInfo ( dev_device ) ) <EOL> dev_info . add ( ( dev_device . server_name , dev_device . ring_name , <EOL> dev_device . swift_drive_name , dev_device . device_name ) ) <EOL> self . assertEqual ( len ( dev_devices ) , <NUM_LIT> ) <EOL> dev_expected = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> ] <EOL> for dev in set ( dev_expected ) : <EOL> self . assertTrue ( dev in dev_info , '<STR_LIT>' % ( <EOL> dev , dev_info ) ) <EOL> dev_info . remove ( dev ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( dev_info ) , '<STR_LIT>' % dev_info ) </s>
