def test_multiple_matched(self):
        group = RateLimiterGroup(limits=[{
            'tag': 'tag1',
            'period_sec': 1,
            'count': 2
        }])
        wrap_defs = [
            {
                'regex': 'method1',
                'tags': ['tag1'],
                'count': 1
            },
            {
                'regex': 'method1',
                'tags': ['tag1'],
                'count': 1
            },
        ]
        object = Class1()
        wrap_object(object, rate_limiter_group=group, wrap_defs=wrap_defs)

        self.assertEqual(object.method1(), 1)
        self.assertEqual(group.status_info(), [{
            'tag': 'tag1',
            'recent_count': 2,
        }])
    def test_other_object_not_changed(self):
        group = RateLimiterGroup(limits=[{
            'tag': 'tag1',
            'period_sec': 1,
            'count': 1
        }])
        wrap_defs = [
            {
                'regex': 'method1',
                'tags': ['tag1'],
                'count': 1
            },
        ]
        object = Class1()
        other_object_before = Class1()
        wrap_object(object, rate_limiter_group=group, wrap_defs=wrap_defs)
        other_object_after = Class1()

        self.assertEqual(other_object_before.method1(), 1)
        self.assertEqual(other_object_after.method1(), 1)
        self.assertEqual(group.status_info(), [{
            'tag': 'tag1',
            'recent_count': 0,
        }])

        self.assertEqual(object.method1(), 1)
        self.assertEqual(group.status_info(), [{
            'tag': 'tag1',
            'recent_count': 1,
        }])
 def _create_ftx(self):
     ftx = ccxt.ftx({
         'enableRateLimit': False,
     })
     wrap_object(ftx,
                 rate_limiter_group=self.ftx_rate_limiter,
                 wrap_defs=ftx_wrap_defs())
     return ftx
 def _create_bybit(self):
     bybit = ccxt.bybit({
         'enableRateLimit': False,
     })
     wrap_object(bybit,
                 rate_limiter_group=self.bybit_rate_limiter,
                 wrap_defs=bybit_wrap_defs())
     return bybit