<s> """<STR_LIT>""" <EOL> import mock <EOL> from src import basetest <EOL> from src . hadoop import datastore <EOL> from src . pipelines . stages import hadoopshutdown <EOL> class ShutdownHadoopClusterTest ( basetest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( basetest . TestCase , self ) . setUp ( ) <EOL> self . mock_hadoop_cluster_class = mock . patch ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . start ( ) <EOL> self . mock_hadoop_cluster = self . mock_hadoop_cluster_class . return_value <EOL> def tearDown ( self ) : <EOL> mock . patch . stopall ( ) <EOL> super ( basetest . TestCase , self ) . tearDown ( ) <EOL> def _PrepareClusterInfo ( self ) : <EOL> """<STR_LIT>""" <EOL> cluster_info = datastore . ClusterInfo ( <EOL> project = '<STR_LIT>' , prefix = '<STR_LIT>' ) <EOL> cluster_info . put ( ) <EOL> return cluster_info <EOL> def testShutdownCluster ( self ) : <EOL> """<STR_LIT>""" <EOL> cluster_info = self . _PrepareClusterInfo ( ) <EOL> hadoopshutdown . ShutdownHadoopCluster ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> self . assertEqual ( <NUM_LIT:1> , self . mock_hadoop_cluster_class . call_count ) <EOL> args = self . mock_hadoop_cluster_class . call_args <EOL> self . assertEqual ( cluster_info . key . id ( ) , args [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) <EOL> self . mock_hadoop_cluster . TeardownCluster . assert_called_once_with ( ) <EOL> def testShutdownNonExistingCluster ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( hadoopshutdown . HadoopShutdownError , <EOL> hadoopshutdown . ShutdownHadoopCluster , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def testProjectRequired ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _PrepareClusterInfo ( ) <EOL> self . assertRaises ( hadoopshutdown . HadoopShutdownError , <EOL> hadoopshutdown . ShutdownHadoopCluster , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def testPrefixRequired ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _PrepareClusterInfo ( ) <EOL> self . assertRaises ( hadoopshutdown . HadoopShutdownError , <EOL> hadoopshutdown . ShutdownHadoopCluster , <EOL> { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> basetest . main ( ) </s>
