class AuthFailedBackendTest(TestCase):
  
    def setUp(self):
        self.be = AuthFailedLoggerBackend()

    def test_log_is_empty(self):
        self.assertEquals(m.FailedLoginLog.objects.count(), 0)
 
    def test_authenticate_is_logged(self):
        self.be.authenticate()
        self.assertEquals(m.FailedLoginLog.objects.count(), 1)

    def test_authenticate_request_logs_username(self):
        self.be.authenticate(username='******')
        log = m.FailedLoginLog.objects.all()[0]
        self.assertEquals(log.username, 'some_user')
        self.assertTrue(is_recent(log.timestamp), 'Should have logged it recently')
 def setUp(self):
     self.be = AuthFailedLoggerBackend()