Changes test IPs to non-routable values, clears from throttle at end of test and adds checks to ensure manual key eviction works.

This commit is contained in:
Johnny 2020-10-20 21:01:20 +00:00
parent 5773d4c0cb
commit 78a32e2a3d

View file

@ -90,8 +90,8 @@ class ThrottleTest(EvenniaTest):
"""
def test_throttle(self):
ips = ("94.100.176.153", "45.56.148.77", "5.196.1.129")
kwargs = {"limit": 5, "timeout": 15 * 60}
ips = ("256.256.256.257", "257.257.257.257", "258.258.258.258")
kwargs = {"name": "testing", "limit": 5, "timeout": 15 * 60}
throttle = Throttle(**kwargs)
@ -124,3 +124,14 @@ class ThrottleTest(EvenniaTest):
# There should only be (cache_size * num_ips) total in the Throttle cache
self.assertEqual(sum([len(cache[x]) for x in cache.keys()]), throttle.cache_size * len(ips))
# Make sure the cache is populated
self.assertTrue(throttle.get())
# Remove the test IPs from the throttle cache
# (in case persistent storage was configured by the user)
for ip in ips:
self.assertTrue(throttle.remove(ip))
# Make sure the cache is empty
self.assertFalse(throttle.get())