#NEWLINE# def test_resolved_answers_handler( self ) : #NEWLINE# #INDENT# exploration_dict = self . get_json ( ( '%s/0' % feconf . EXPLORATION_INIT_URL_PREFIX ) ) #NEWLINE# self . assertEqual ( exploration_dict [ 'exploration' ] [ 'title' ] , 'Welcome to Oppia!' ) #NEWLINE# state_name = exploration_dict [ 'exploration' ] [ 'init_state_name' ] #NEWLINE# result_dict = self . submit_answer ( '0' , state_name , '0' ) #NEWLINE# state_name = result_dict [ 'state_name' ] #NEWLINE# self . submit_answer ( '0' , state_name , 'blah' ) #NEWLINE# for _ in range ( 2 ) : #NEWLINE# #INDENT# self . submit_answer ( '0' , state_name , 'blah2' ) #NEWLINE# #UNINDENT# for _ in range ( 3 ) : #NEWLINE# #INDENT# self . submit_answer ( '0' , state_name , 'blah3' ) #NEWLINE# #UNINDENT# self . login ( self . EDITOR_EMAIL ) #NEWLINE# response = self . testapp . get ( '/create/0' ) #NEWLINE# csrf_token = self . get_csrf_token_from_response ( response ) #NEWLINE# url = str ( ( '/createhandler/resolved_answers/0/%s' % state_name ) ) #NEWLINE# def _get_unresolved_answers( ) : #NEWLINE# #INDENT# return stats_domain . StateRuleAnswerLog . get ( '0' , state_name , exp_domain . DEFAULT_RULESPEC_STR ) . answers #NEWLINE# #UNINDENT# self . assertEqual ( _get_unresolved_answers ( ) , { #NEWLINE# #INDENT# 'blah' : 1 , #NEWLINE# 'blah2' : 2 , #NEWLINE# 'blah3' : 3 , #NEWLINE# #UNINDENT# } ) #NEWLINE# response_dict = self . put_json ( url , { #NEWLINE# #INDENT# 'something_else' : [ ] , #NEWLINE# #UNINDENT# } , csrf_token , expect_errors = True , expected_status_int = 400 ) #NEWLINE# self . assertIn ( 'Expected a list' , response_dict [ 'error' ] ) #NEWLINE# response_dict = self . put_json ( url , { #NEWLINE# #INDENT# 'resolved_answers' : 'this_is_a_string' , #NEWLINE# #UNINDENT# } , csrf_token , expect_errors = True , expected_status_int = 400 ) #NEWLINE# self . assertIn ( 'Expected a list' , response_dict [ 'error' ] ) #NEWLINE# response_dict = self . put_json ( url , { #NEWLINE# #INDENT# 'resolved_answers' : [ 'not_submitted_answer' ] , #NEWLINE# #UNINDENT# } , csrf_token ) #NEWLINE# self . assertEqual ( _get_unresolved_answers ( ) , { #NEWLINE# #INDENT# 'blah' : 1 , #NEWLINE# 'blah2' : 2 , #NEWLINE# 'blah3' : 3 , #NEWLINE# #UNINDENT# } ) #NEWLINE# response_dict = self . put_json ( url , { #NEWLINE# #INDENT# 'resolved_answers' : [ 'blah' ] , #NEWLINE# #UNINDENT# } , csrf_token ) #NEWLINE# self . assertEqual ( _get_unresolved_answers ( ) , { #NEWLINE# #INDENT# 'blah2' : 2 , #NEWLINE# 'blah3' : 3 , #NEWLINE# #UNINDENT# } ) #NEWLINE# response_dict = self . put_json ( url , { #NEWLINE# #INDENT# 'resolved_answers' : [ 'blah2' , 'blah3' ] , #NEWLINE# #UNINDENT# } , csrf_token ) #NEWLINE# self . assertEqual ( _get_unresolved_answers ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# self . logout ( )