def test_add_remove_rule(self) -> None: user_profile = self.example_user("hamlet") add_ratelimit_rule(1, 2) add_ratelimit_rule(4, 5, domain='some_new_domain') add_ratelimit_rule(10, 100, domain='some_new_domain') obj = RateLimitedUser(user_profile) self.assertEqual(obj.rules(), [ (1, 2), ]) obj.domain = 'some_new_domain' self.assertEqual(obj.rules(), [(4, 5), (10, 100)]) remove_ratelimit_rule(10, 100, domain='some_new_domain') self.assertEqual(obj.rules(), [ (4, 5), ])
def test_user_rate_limits(self) -> None: user_profile = self.example_user("hamlet") user_profile.rate_limits = "1:3,2:4" obj = RateLimitedUser(user_profile) self.assertEqual(obj.rules(), [(1, 3), (2, 4)])