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')
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)
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')
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)
def test_timing(): with stub_client() as stub: statsdecor.timing('a.metric', 314159265359) stub.client.timing.assert_called_with('a.metric', 314159265359, 1)
def test_timer(): with stub_client() as stub: statsdecor.timer('a.metric') assert stub.client.timer.called, 'Should be called'
def test_incr(): with stub_client() as stub: statsdecor.incr('a.metric') stub.client.incr.assert_called_with('a.metric', 1, 1)
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)
def test_gauge(): with stub_client() as stub: statsdecor.gauge('a.metric', 8) stub.client.gauge.assert_called_with('a.metric', 8, 1)
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)