Skip to content

Commit

Permalink
add test for counting connector metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrai2 committed Oct 20, 2023
1 parent 9279c94 commit 7af46a4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/connector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ def test_get_next_doesnt_count_numer_of_processed_events_if_event_is_none(self):
self.object.get_next(0.01)
assert self.object.metrics.number_of_processed_events == 0

def test_get_next_has_time_measurement(self):
self.object.metrics.processing_time_per_event = mock.MagicMock()
self.object.metrics.processing_time_per_event.__iadd__ = mock.MagicMock()
return_value = ({"message": "test message"}, b'{"message": "test message"}')
self.object._get_event = mock.MagicMock(return_value=return_value)
self.object.get_next(0.01)
assert isinstance(self.object.metrics.processing_time_per_event, mock.MagicMock)
self.object.metrics.processing_time_per_event.__iadd__.assert_called()


class BaseOutputTestCase(BaseConnectorTestCase):
def test_is_output_instance(self):
Expand All @@ -532,6 +541,11 @@ def test_store_counts_processed_events(self):
self.object.store({"message": "my event message"})
assert self.object.metrics.number_of_processed_events == 1

def test_store_failed_counts_failed_events(self):
self.object.metrics.number_of_failed_events = 0
self.object.store_failed("error", {"message": "my event message"}, {})
assert self.object.metrics.number_of_failed_events == 1

def test_store_calls_batch_finished_callback(self):
self.object.input_connector = mock.MagicMock()
self.object.store({"message": "my event message"})
Expand Down

0 comments on commit 7af46a4

Please sign in to comment.