コード例 #1
0
ファイル: test_base_limiter.py プロジェクト: scorphus/octopus
class TestBaseLimiter(TestCase):
    def setUp(self):
        super(TestBaseLimiter, self).setUp()
        self.limiter = Limiter()
        self.handled_url = None

    def test_has_bus(self):
        expect(self.limiter.bus).not_to_be_null()

    def test_can_subscribe(self):
        def handle_lock_miss(url):
            pass

        self.limiter.subscribe_to_lock_miss(handle_lock_miss)

        expect(self.limiter.bus.has_any_subscriptions(
            'limiter.miss')).to_be_true()

    def test_can_get_lock_miss(self):
        def handle_lock_miss(url):
            self.handled_url = url

        self.limiter.subscribe_to_lock_miss(handle_lock_miss)

        self.limiter.publish_lock_miss('some-url')

        expect(self.handled_url).to_equal('some-url')
コード例 #2
0
class TestBaseLimiter(TestCase):
    def setUp(self):
        super(TestBaseLimiter, self).setUp()
        self.limiter = Limiter()
        self.handled_url = None

    def test_has_bus(self):
        expect(self.limiter.bus).not_to_be_null()

    def test_can_subscribe(self):
        def handle_lock_miss(url):
            pass

        self.limiter.subscribe_to_lock_miss(handle_lock_miss)

        expect(self.limiter.bus.has_any_subscriptions('limiter.miss')).to_be_true()

    def test_can_get_lock_miss(self):
        def handle_lock_miss(url):
            self.handled_url = url

        self.limiter.subscribe_to_lock_miss(handle_lock_miss)

        self.limiter.publish_lock_miss('some-url')

        expect(self.handled_url).to_equal('some-url')
コード例 #3
0
ファイル: test_base_limiter.py プロジェクト: scorphus/octopus
 def setUp(self):
     super(TestBaseLimiter, self).setUp()
     self.limiter = Limiter()
     self.handled_url = None
コード例 #4
0
 def setUp(self):
     super(TestBaseLimiter, self).setUp()
     self.limiter = Limiter()
     self.handled_url = None