#NEWLINE# @ mock . patch ( 'h.nipsa.models.NipsaUser' ) #NEWLINE# def test_add_nipsa_adds_user_if_user_does_not_exist( NipsaUser ) : #NEWLINE# #INDENT# request = mock . Mock ( ) #NEWLINE# nipsa_user = mock . Mock ( ) #NEWLINE# NipsaUser . return_value = nipsa_user #NEWLINE# NipsaUser . get_by_userid . return_value = None #NEWLINE# logic . add_nipsa ( request = request , userid = 'test_id' ) #NEWLINE# NipsaUser . assert_called_once_with ( 'test_id' ) #NEWLINE# request . db . add . assert_called_once_with ( nipsa_user )