Example #1
0
def test_decrement():
    @decorators.decrement('a.metric')
    def test_fn(*args, **kwargs):
        assert_arguments(args, kwargs)

    with stub_client('statsdecor.decorators.client') as stub:
        test_fn('some', 'thing', key='value')
        stub.client.decr.assert_called_with('a.metric')
Example #2
0
    def test_increment__with_tags(self):
        @decorators.increment('a.metric', tags=self.tags)
        def test_fn(*args, **kwargs):
            assert_arguments(args, kwargs)

        with stub_client(self.client_class,
                         'statsdecor.decorators.client') as stub:
            test_fn('some', 'thing', key='value')
            stub.client.incr.assert_called_with('a.metric', tags=self.tags)
Example #3
0
def test_timed():
    @decorators.timed('a.metric')
    def test_fn(*args, **kwargs):
        assert_arguments(args, kwargs)

    with stub_client('statsdecor.decorators.client') as stub:
        # Stub out the timing context manager.
        stub.client.timer.return_value = MagicMock()
        test_fn('some', 'thing', key='value')
        stub.client.timer.assert_called_with('a.metric')
Example #4
0
def test_timing__with_value_and_rate():
    with stub_client() as stub:
        statsdecor.timing('a.metric', 314159265359, 0.1)
        stub.client.timing.assert_called_with('a.metric', 314159265359, 0.1)
Example #5
0
def test_timing():
    with stub_client() as stub:
        statsdecor.timing('a.metric', 314159265359)
        stub.client.timing.assert_called_with('a.metric', 314159265359, 1)
Example #6
0
def test_timer():
    with stub_client() as stub:
        statsdecor.timer('a.metric')
        assert stub.client.timer.called, 'Should be called'
Example #7
0
def test_incr():
    with stub_client() as stub:
        statsdecor.incr('a.metric')
        stub.client.incr.assert_called_with('a.metric', 1, 1)
Example #8
0
def test_gauge__with_value_and_rate():
    with stub_client() as stub:
        statsdecor.gauge('a.metric', 9, 0.1)
        stub.client.gauge.assert_called_with('a.metric', 9, 0.1)
Example #9
0
def test_gauge():
    with stub_client() as stub:
        statsdecor.gauge('a.metric', 8)
        stub.client.gauge.assert_called_with('a.metric', 8, 1)
Example #10
0
def test_gauge():
    with stub_client() as stub:
        statsdecor.gauge('a.metric', 8)
        stub.client.gauge.assert_called_with('a.metric', 8, 1)
Example #11
0
def test_timing__with_value_and_rate():
    with stub_client() as stub:
        statsdecor.timing('a.metric', 314159265359, 0.1)
        stub.client.timing.assert_called_with('a.metric', 314159265359, 0.1)
Example #12
0
def test_timing():
    with stub_client() as stub:
        statsdecor.timing('a.metric', 314159265359)
        stub.client.timing.assert_called_with('a.metric', 314159265359, 1)
Example #13
0
def test_timer():
    with stub_client() as stub:
        statsdecor.timer('a.metric')
        assert stub.client.timer.called, 'Should be called'
Example #14
0
def test_incr():
    with stub_client() as stub:
        statsdecor.incr('a.metric')
        stub.client.incr.assert_called_with('a.metric', 1, 1)
Example #15
0
def test_gauge__with_value_and_rate():
    with stub_client() as stub:
        statsdecor.gauge('a.metric', 9, 0.1)
        stub.client.gauge.assert_called_with('a.metric', 9, 0.1)
Example #16
0
def test_decr__with_value_and_rate():
    with stub_client() as stub:
        statsdecor.decr('a.metric', 9, 0.1)
        stub.client.decr.assert_called_with('a.metric', 9, 0.1)
Example #17
0
def test_decr__with_value_and_rate():
    with stub_client() as stub:
        statsdecor.decr('a.metric', 9, 0.1)
        stub.client.decr.assert_called_with('a.metric', 9, 0.1)