def test_should_rate_limit_returns_true_when_limited(
         self, mock_time, mock_ltrim, mock_lindex):
     self.assertTrue(authorization.should_rate_limit("test"))
 def test_should_rate_limit_calls_lindex(self, mock_lindex, mock_ltrim,
                                         mock_lpush):
     authorization.should_rate_limit("test")
     mock_lindex.assert_called_once_with("request:test", 1, decode=False)
 def test_should_rate_limit_calls_lpush_when_returning_false(
         self, mock_time, mock_lpush, mock_ltrim, mock_lindex):
     self.assertFalse(authorization.should_rate_limit("test"))
     mock_lpush.assert_called_once_with("request:test",
                                        "1554249099.7634845")
 def test_should_rate_limit_calls_ltrim(self, mock_ltrim, mock_rand,
                                        mock_lpush, mock_lindex):
     authorization.should_rate_limit("test")
     mock_ltrim.assert_called_once_with("request:test", 0, 1)
 def test_should_rate_limit_disabled_on_0(self, mock_lindex):
     self.assertFalse(authorization.should_rate_limit("test"))
     mock_lindex.assert_not_called()