@@ -515,7 +515,7 @@ def test_spark_unexpected_exception_in_storing():
515515 spark_controller .run_command = MagicMock (side_effect = side_effect )
516516
517517 magic .spark (line , cell )
518- assert spark_controller .run_command .call_count == 2
518+ assert_equals ( spark_controller .run_command .call_count , 2 )
519519 spark_controller .run_command .assert_any_call (Command (cell ), None )
520520 ipython_display .send_error .assert_called_with (constants .INTERNAL_ERROR_MSG
521521 .format (side_effect [1 ]))
@@ -535,15 +535,24 @@ def test_spark_expected_exception_in_storing():
535535 .format (side_effect [1 ]))
536536
537537
538-
539538@with_setup (_setup , _teardown )
540539def test_spark_sample_options ():
541- line = "-o var_name -m sample -n 142 -r 0.3"
540+ line = "-o var_name -m sample -n 142 -r 0.3 -c True"
541+ cell = ""
542+ magic .execute_spark = MagicMock ()
543+ ret = magic .spark (line , cell )
544+
545+ magic .execute_spark .assert_called_once_with (cell , "var_name" , "sample" , 142 , 0.3 , None , True )
546+
547+
548+ @with_setup (_setup , _teardown )
549+ def test_spark_false_coerce ():
550+ line = "-o var_name -m sample -n 142 -r 0.3 -c False"
542551 cell = ""
543552 magic .execute_spark = MagicMock ()
544553 ret = magic .spark (line , cell )
545554
546- magic .execute_spark .assert_called_once_with (cell , "var_name" , "sample" , 142 , 0.3 , None )
555+ magic .execute_spark .assert_called_once_with (cell , "var_name" , "sample" , 142 , 0.3 , None , False )
547556
548557
549558@with_setup (_setup , _teardown )
@@ -556,7 +565,7 @@ def test_sql_without_output():
556565
557566 spark_controller .add_session .assert_called_once_with (magic .session_name , magic .endpoint , False ,
558567 {"kind" : constants .SESSION_KIND_PYSPARK })
559- magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , None , False )
568+ magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , None , False , None )
560569
561570
562571@with_setup (_setup , _teardown )
@@ -569,7 +578,7 @@ def test_sql_with_output():
569578
570579 spark_controller .add_session .assert_called_once_with (magic .session_name , magic .endpoint , False ,
571580 {"kind" : constants .SESSION_KIND_PYSPARK })
572- magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "my_var" , False )
581+ magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "my_var" , False , None )
573582
574583
575584@with_setup (_setup , _teardown )
@@ -579,7 +588,7 @@ def test_sql_exception():
579588 magic .execute_sqlquery = MagicMock (side_effect = ValueError ('HAHAHAHAH' ))
580589
581590 magic .sql (line , cell )
582- magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "my_var" , False )
591+ magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "my_var" , False , None )
583592 ipython_display .send_error .assert_called_once_with (constants .INTERNAL_ERROR_MSG
584593 .format (magic .execute_sqlquery .side_effect ))
585594
@@ -591,7 +600,7 @@ def test_sql_expected_exception():
591600 magic .execute_sqlquery = MagicMock (side_effect = HttpClientException ('HAHAHAHAH' ))
592601
593602 magic .sql (line , cell )
594- magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "my_var" , False )
603+ magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "my_var" , False , None )
595604 ipython_display .send_error .assert_called_once_with (constants .EXPECTED_ERROR_MSG
596605 .format (magic .execute_sqlquery .side_effect ))
597606
@@ -619,20 +628,33 @@ def test_sql_quiet():
619628
620629 spark_controller .add_session .assert_called_once_with (magic .session_name , magic .endpoint , False ,
621630 {"kind" : constants .SESSION_KIND_PYSPARK })
622- magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "Output" , True )
631+ magic .execute_sqlquery .assert_called_once_with (cell , None , None , None , None , "Output" , True , None )
623632
624633
625634@with_setup (_setup , _teardown )
626635def test_sql_sample_options ():
627- line = "-q -m sample -n 142 -r 0.3"
636+ line = "-q -m sample -n 142 -r 0.3 -c True"
637+ cell = ""
638+ magic .execute_sqlquery = MagicMock ()
639+
640+ ret = magic .sql (line , cell )
641+
642+ spark_controller .add_session .assert_called_once_with (magic .session_name , magic .endpoint , False ,
643+ {"kind" : constants .SESSION_KIND_PYSPARK })
644+ magic .execute_sqlquery .assert_called_once_with (cell , "sample" , 142 , 0.3 , None , None , True , True )
645+
646+
647+ @with_setup (_setup , _teardown )
648+ def test_sql_false_coerce ():
649+ line = "-q -m sample -n 142 -r 0.3 -c False"
628650 cell = ""
629651 magic .execute_sqlquery = MagicMock ()
630652
631653 ret = magic .sql (line , cell )
632654
633655 spark_controller .add_session .assert_called_once_with (magic .session_name , magic .endpoint , False ,
634656 {"kind" : constants .SESSION_KIND_PYSPARK })
635- magic .execute_sqlquery .assert_called_once_with (cell , "sample" , 142 , 0.3 , None , None , True )
657+ magic .execute_sqlquery .assert_called_once_with (cell , "sample" , 142 , 0.3 , None , None , True , False )
636658
637659
638660@with_setup (_setup , _teardown )
0 commit comments