@@ -384,6 +384,7 @@ def test_rendering(self):
384
384
'linenumbers' : 'true' ,
385
385
'hidden' : '' ,
386
386
'tabsize' : int (self .tabsize ),
387
+ 'button_enabled' : True ,
387
388
'queue_len' : '3' }
388
389
389
390
self .assertEqual (context , expected )
@@ -409,10 +410,37 @@ def test_rendering_with_state(self):
409
410
'linenumbers' : 'true' ,
410
411
'hidden' : '' ,
411
412
'tabsize' : int (self .tabsize ),
413
+ 'button_enabled' : True ,
412
414
'queue_len' : '3' }
413
415
414
416
self .assertEqual (context , expected )
415
417
418
+ def test_rendering_when_completed (self ):
419
+ for status in ['correct' , 'incorrect' ]:
420
+ state = {'value' : 'print "good evening"' ,
421
+ 'status' : status ,
422
+ 'input_state' : {},
423
+ }
424
+ elt = etree .fromstring (self .xml )
425
+
426
+ the_input = self .input_class (test_system , elt , state )
427
+ context = the_input ._get_render_context ()
428
+ expected = {'id' : 'prob_1_2' ,
429
+ 'value' : 'print "good evening"' ,
430
+ 'status' : status ,
431
+ 'msg' : '' ,
432
+ 'mode' : self .mode ,
433
+ 'rows' : self .rows ,
434
+ 'cols' : self .cols ,
435
+ 'queue_msg' : '' ,
436
+ 'linenumbers' : 'true' ,
437
+ 'hidden' : '' ,
438
+ 'tabsize' : int (self .tabsize ),
439
+ 'button_enabled' : False ,
440
+ 'queue_len' : '0' }
441
+
442
+ self .assertEqual (context , expected )
443
+
416
444
def test_rendering_while_queued (self ):
417
445
state = {'value' : 'print "good evening"' ,
418
446
'status' : 'incomplete' ,
@@ -433,6 +461,7 @@ def test_rendering_while_queued(self):
433
461
'linenumbers' : 'true' ,
434
462
'hidden' : '' ,
435
463
'tabsize' : int (self .tabsize ),
464
+ 'button_enabled' : True ,
436
465
'queue_len' : '1' }
437
466
438
467
self .assertEqual (context , expected )
@@ -447,6 +476,17 @@ def test_plot_data(self):
447
476
self .assertTrue (self .the_input .input_state ['queuekey' ] is not None )
448
477
self .assertEqual (self .the_input .input_state ['queuestate' ], 'queued' )
449
478
479
+ def test_plot_data_failure (self ):
480
+ get = {'submission' : 'x = 1234;' }
481
+ error_message = 'Error message!'
482
+ test_system .xqueue ['interface' ].send_to_queue .return_value = (1 , error_message )
483
+ response = self .the_input .handle_ajax ("plot" , get )
484
+ self .assertFalse (response ['success' ])
485
+ self .assertEqual (response ['message' ], error_message )
486
+ self .assertTrue ('queuekey' not in self .the_input .input_state )
487
+ self .assertTrue ('queuestate' not in self .the_input .input_state )
488
+ test_system .xqueue ['interface' ].send_to_queue .return_value = (0 , 'Success!' )
489
+
450
490
def test_ungraded_response_success (self ):
451
491
queuekey = 'abcd'
452
492
input_state = {'queuekey' : queuekey , 'queuestate' : 'queued' }
@@ -583,7 +623,6 @@ def test_corrupt_values(self):
583
623
self .check ('[12 13 14]' , 0 , 0 )
584
624
585
625
586
-
587
626
class CrystallographyTest (unittest .TestCase ):
588
627
'''
589
628
Check that crystallography inputs work
@@ -613,8 +652,7 @@ def test_rendering(self):
613
652
'status' : 'unsubmitted' ,
614
653
'msg' : '' ,
615
654
'width' : width ,
616
- 'height' : height ,
617
- }
655
+ 'height' : height }
618
656
619
657
self .assertEqual (context , expected )
620
658
@@ -654,13 +692,11 @@ def test_rendering(self):
654
692
'width' : width ,
655
693
'height' : height ,
656
694
'molecules' : molecules ,
657
- 'geometries' : geometries ,
658
- }
695
+ 'geometries' : geometries }
659
696
660
697
self .assertEqual (context , expected )
661
698
662
699
663
-
664
700
class ChemicalEquationTest (unittest .TestCase ):
665
701
'''
666
702
Check that chemical equation inputs work.
@@ -674,7 +710,6 @@ def setUp(self):
674
710
state = {'value' : 'H2OYeah' , }
675
711
self .the_input = lookup_tag ('chemicalequationinput' )(test_system , element , state )
676
712
677
-
678
713
def test_rendering (self ):
679
714
''' Verify that the render context matches the expected render context'''
680
715
context = self .the_input ._get_render_context ()
@@ -688,10 +723,8 @@ def test_rendering(self):
688
723
}
689
724
self .assertEqual (context , expected )
690
725
691
-
692
726
def test_chemcalc_ajax_sucess (self ):
693
727
''' Verify that using the correct dispatch and valid data produces a valid response'''
694
-
695
728
data = {'formula' : "H" }
696
729
response = self .the_input .handle_ajax ("preview_chemcalc" , data )
697
730
@@ -700,9 +733,6 @@ def test_chemcalc_ajax_sucess(self):
700
733
self .assertEqual (response ['error' ], "" )
701
734
702
735
703
-
704
-
705
-
706
736
class DragAndDropTest (unittest .TestCase ):
707
737
'''
708
738
Check that drag and drop inputs work
0 commit comments