<s> import os <EOL> import pytest <EOL> from pyleus . cli . storm_cluster import _get_storm_cmd_env <EOL> from pyleus . cli . storm_cluster import STORM_JAR_JVM_OPTS <EOL> from pyleus . cli . storm_cluster import StormCluster <EOL> from pyleus . cli . storm_cluster import TOPOLOGY_BUILDER_CLASS <EOL> from pyleus . testing import mock <EOL> class TestGetStormCmdEnd ( object ) : <EOL> @ pytest . fixture ( autouse = True ) <EOL> def mock_os_environ ( self , monkeypatch ) : <EOL> monkeypatch . setattr ( os , '<STR_LIT>' , { } ) <EOL> def test_jvm_opts_unset ( self ) : <EOL> assert _get_storm_cmd_env ( None ) is None <EOL> def test_jvm_opts_set ( self ) : <EOL> jvm_opts = "<STR_LIT>" <EOL> env = _get_storm_cmd_env ( jvm_opts ) <EOL> assert env [ STORM_JAR_JVM_OPTS ] == jvm_opts <EOL> class TestStormCluster ( object ) : <EOL> @ pytest . fixture <EOL> def cluster ( self ) : <EOL> return StormCluster ( <EOL> mock . sentinel . storm_cmd_path , <EOL> mock . sentinel . nimbus_host , <EOL> mock . sentinel . nimbus_port , <EOL> mock . sentinel . verbose , <EOL> mock . sentinel . jvm_opts , <EOL> ) <EOL> def test__build_storm_cmd_no_port ( self , cluster ) : <EOL> cluster . nimbus_host = "<STR_LIT>" <EOL> cluster . nimbus_port = None <EOL> storm_cmd = cluster . _build_storm_cmd ( [ "<STR_LIT:a>" , "<STR_LIT>" ] ) <EOL> assert storm_cmd == [ mock . sentinel . storm_cmd_path , "<STR_LIT:a>" , "<STR_LIT>" , "<STR_LIT:-c>" , <EOL> "<STR_LIT>" ] <EOL> def test__build_storm_cmd_with_port ( self , cluster ) : <EOL> cluster . nimbus_host = "<STR_LIT>" <EOL> cluster . nimbus_port = <NUM_LIT> <EOL> storm_cmd = cluster . _build_storm_cmd ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> assert storm_cmd == [ mock . sentinel . storm_cmd_path , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:-c>" , <EOL> "<STR_LIT>" , "<STR_LIT:-c>" , <EOL> "<STR_LIT>" ] <EOL> def test_submit ( self , cluster ) : <EOL> with mock . patch . object ( cluster , '<STR_LIT>' , autospec = True ) as mock_exec : <EOL> cluster . submit ( mock . sentinel . jar_path ) <EOL> mock_exec . assert_called_once_with ( [ "<STR_LIT>" , mock . sentinel . jar_path , TOPOLOGY_BUILDER_CLASS ] ) </s>
