#NEWLINE# @ patch ( 'nopassword.backends.sms.TwilioRestClient' ) #NEWLINE# def test_twilio_backend( self , mock_object ) : #NEWLINE# #INDENT# self . backend = TwilioBackend ( ) #NEWLINE# self . backend . twilio_client . messages . create = MagicMock ( ) #NEWLINE# self . backend . send_login_code ( self . code ) #NEWLINE# self . assertTrue ( mock_object . called ) #NEWLINE# self . assertTrue ( self . backend . twilio_client . messages . create . called ) #NEWLINE# ( _ , kwargs ) = self . backend . twilio_client . messages . create . call_args #NEWLINE# self . assertIn ( self . code . login_url ( secure = False ) , kwargs . get ( 'body' ) ) #NEWLINE# authenticate ( username = self . user . username ) #NEWLINE# self . assertEqual ( LoginCode . objects . filter ( user = self . user ) . count ( ) , 1 )