#NEWLINE# def test_score( db_conn , responses_table ) : #NEWLINE# #INDENT# '\n    Expect to have a score between 0 and 1 (including).\n    ' #NEWLINE# ( response , errors ) = Response . insert ( db_conn , { #NEWLINE# #INDENT# 'user_id' : 'A' , #NEWLINE# 'card_id' : 'BC' , #NEWLINE# 'unit_id' : 'RM' , #NEWLINE# 'response' : 42 , #NEWLINE# 'learned' : 0.9 , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( len ( errors ) == 1 ) #NEWLINE# response [ 'score' ] = 1.1 #NEWLINE# ( response , errors ) = response . save ( db_conn ) #NEWLINE# assert ( len ( errors ) == 1 ) #NEWLINE# response [ 'score' ] = 0 #NEWLINE# ( response , errors ) = response . save ( db_conn ) #NEWLINE# assert ( len ( errors ) == 0 ) #NEWLINE# response [ 'score' ] = 1 #NEWLINE# ( response , errors ) = response . save ( db_conn ) #NEWLINE# assert ( len ( db_conn ) == 0 )