#NEWLINE# @ mock . patch ( 'h.nipsa.models.NipsaUser' ) #NEWLINE# def test_add_nipsa_schedules_task_when_user_already_exists( NipsaUser , worker ) : #NEWLINE# #INDENT# '\n    Even if the user is already NIPSA\'d, add_nipsa() should still schedule an\n    "add_nipsa" task.\n    ' #NEWLINE# nipsa_user = mock . Mock ( ) #NEWLINE# NipsaUser . get_by_userid . return_value = nipsa_user #NEWLINE# request = mock . Mock ( ) #NEWLINE# logic . add_nipsa ( request = request , userid = 'test_id' ) #NEWLINE# worker . add_nipsa . delay . assert_called_once_with ( 'test_id' ) #NEWLINE# NipsaUser . get_by_userid . assert_called_once_with ( 'test_id' )