<s> import six <EOL> import sahara . plugins . mapr . abstract . cluster_context as abstract_context <EOL> from sahara . plugins . mapr . domain import service as bs <EOL> from sahara . plugins . mapr . services . management import management <EOL> from sahara . plugins . mapr . services . maprfs import maprfs <EOL> from sahara . plugins . mapr . services . oozie import oozie <EOL> from sahara . plugins . mapr . services . yarn import yarn <EOL> import sahara . plugins . mapr . versions . v5_0_0_mrv2 . version_handler as handler <EOL> from sahara . plugins import provisioning as p <EOL> from sahara . tests . unit import base as b <EOL> from sahara . tests . unit import testutils as tu <EOL> class TestHandler ( b . SaharaTestCase ) : <EOL> def __init__ ( self , * args , ** kwds ) : <EOL> super ( TestHandler , self ) . __init__ ( * args , ** kwds ) <EOL> self . handler = handler . VersionHandler ( ) <EOL> self . cluster = self . _get_cluster ( ) <EOL> def _get_cluster ( self ) : <EOL> i1 = tu . make_inst_dict ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> master_proc = [ <EOL> yarn . RESOURCE_MANAGER . ui_name , <EOL> yarn . NODE_MANAGER . ui_name , <EOL> yarn . HISTORY_SERVER . ui_name , <EOL> maprfs . CLDB . ui_name , <EOL> maprfs . FILE_SERVER . ui_name , <EOL> oozie . OOZIE . ui_name , <EOL> management . ZOOKEEPER . ui_name , <EOL> ] <EOL> master_ng = tu . make_ng_dict ( '<STR_LIT>' , '<STR_LIT>' , master_proc , <NUM_LIT:1> , [ i1 ] ) <EOL> cluster_configs = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:key>' : '<STR_LIT:value>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } <EOL> cluster = tu . create_cluster ( <EOL> name = '<STR_LIT>' , <EOL> tenant = '<STR_LIT>' , <EOL> plugin = '<STR_LIT>' , <EOL> version = '<STR_LIT>' , <EOL> node_groups = [ master_ng ] , <EOL> cluster_configs = cluster_configs , <EOL> ) <EOL> self . ng = cluster . node_groups [ <NUM_LIT:0> ] <EOL> self . instance = self . ng . instances [ <NUM_LIT:0> ] <EOL> return cluster <EOL> def test_get_context ( self ) : <EOL> self . assertIsInstance ( self . handler . get_context ( self . _get_cluster ( ) ) , <EOL> abstract_context . AbstractClusterContext ) <EOL> def test_get_services ( self ) : <EOL> services = self . handler . get_services ( ) <EOL> for service in services : <EOL> self . assertIsInstance ( service , bs . Service ) <EOL> def test_get_np_dict ( self ) : <EOL> np_dict = self . handler . get_node_processes ( ) <EOL> self . assertIsNotNone ( np_dict ) <EOL> self . assertIsInstance ( np_dict , dict ) <EOL> for k , v in six . iteritems ( np_dict ) : <EOL> self . assertIsInstance ( k , six . string_types ) <EOL> self . assertIsInstance ( v , list ) <EOL> self . assertNotEqual ( <NUM_LIT:0> , len ( v ) ) <EOL> def test_get_configs ( self ) : <EOL> configs = self . handler . get_configs ( ) <EOL> self . assertIsInstance ( configs , list ) <EOL> for config in configs : <EOL> self . assertIsInstance ( config , p . Config ) <EOL> def test_get_version_configs ( self ) : <EOL> version_configs = self . handler . _get_version_configs ( ) <EOL> self . assertIsInstance ( version_configs , list ) <EOL> for conf in version_configs : <EOL> self . assertIsInstance ( conf , p . Config ) <EOL> self . assertNotEqual ( <NUM_LIT:0> , len ( conf . config_values ) ) <EOL> self . assertNotEqual ( <NUM_LIT:1> , len ( conf . config_values ) ) <EOL> self . assertEqual ( '<STR_LIT>' , conf . config_type ) <EOL> def test_get_configs_dict ( self ) : <EOL> configs_dict = self . handler . get_configs_dict ( ) <EOL> self . assertIsInstance ( configs_dict , dict ) <EOL> for k , v in six . iteritems ( configs_dict ) : <EOL> self . assertIsInstance ( k , six . string_types ) <EOL> self . assertIsInstance ( v , dict ) <EOL> def test_get_open_ports ( self ) : <EOL> ports_list = self . handler . get_open_ports ( self . ng ) <EOL> self . assertIsNotNone ( ports_list ) <EOL> self . assertIsInstance ( ports_list , list ) <EOL> for port in ports_list : <EOL> self . assertIsInstance ( port , int ) </s>
