#NEWLINE# @ mock . patch ( 'h.nipsa.models.NipsaUser' ) #NEWLINE# def test_add_nipsa_does_not_add_when_user_already_exists( NipsaUser ) : #NEWLINE# #INDENT# '\n    add_nipsa() should not call db.add() if the user already exists.\n    ' #NEWLINE# request = mock . Mock ( ) #NEWLINE# nipsa_user = mock . Mock ( ) #NEWLINE# NipsaUser . get_by_userid . return_value = NipsaUser #NEWLINE# logic . add_nipsa ( request = request , userid = 'test_id' ) #NEWLINE# assert ( not request . db . add . called )