#NEWLINE# def test_rate_limit_user_or_ip( self ) : #NEWLINE# #INDENT# req = RequestFactory ( ) . get ( '/' ) #NEWLINE# req . user = AnonymousUser ( ) #NEWLINE# setup_request_factory_messages ( req ) #NEWLINE# @ ratelimit ( method = [ 'GET' ] , rate = '1/m' ) #NEWLINE# def limit_ip( request ) : #NEWLINE# #INDENT# return request . is_limited #NEWLINE# #UNINDENT# self . assertFalse ( limit_ip ( req ) ) #NEWLINE# self . assertTrue ( limit_ip ( req ) ) #NEWLINE# req . user = User ( ) #NEWLINE# req . user . pk = 1 #NEWLINE# self . assertFalse ( limit_ip ( req ) ) #NEWLINE# self . assertTrue ( limit_ip ( req ) )