<s> from django . test import TestCase <EOL> from django . test . client import RequestFactory <EOL> from oscar_accounts import security <EOL> class TestBruteForceAPI ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> factory = RequestFactory ( ) <EOL> self . request = factory . post ( '<STR_LIT:/>' ) <EOL> def test_does_not_block_by_default ( self ) : <EOL> self . assertFalse ( security . is_blocked ( self . request ) ) <EOL> def test_blocks_after_freeze_threshold ( self ) : <EOL> for __ in range ( <NUM_LIT:3> ) : <EOL> security . record_failed_request ( self . request ) <EOL> self . assertTrue ( security . is_blocked ( self . request ) ) <EOL> def test_resets_after_success ( self ) : <EOL> for __ in range ( <NUM_LIT:2> ) : <EOL> security . record_failed_request ( self . request ) <EOL> security . record_successful_request ( self . request ) <EOL> security . record_failed_request ( self . request ) <EOL> self . assertFalse ( security . is_blocked ( self . request ) ) </s>
