def test_get_smart_paasta_instance_name(mrjob): args = argparse.Namespace( instance="foo", cmd="USER blah spark-submit blah blah blah", mrjob=mrjob, ) with mock.patch( "paasta_tools.cli.cmds.spark_run.get_username", return_value="root", autospec=True, ): assert (get_smart_paasta_instance_name(args) == "foo_root_mrjob" if mrjob else "foo_root_spark-submit")
def test_get_smart_paasta_instance_name_tron(): args = argparse.Namespace( instance="foo", cmd="spark-submit blah blah blah", mrjob=True, ) with mock.patch( "paasta_tools.cli.cmds.spark_run.os.environ", dict( TRON_JOB_NAMESPACE="master", TRON_JOB_NAME="yelp-main", TRON_ACTION="rm_rf_slash", ), autospec=None, ): assert get_smart_paasta_instance_name(args) == "yelp-main.rm_rf_slash"