Skip to content

Commit

Permalink
fix dummy input
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Sep 6, 2024
1 parent 683e610 commit 0a4a809
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/unit/connector/test_dummy_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ def test_fails_with_disconnected_error_if_input_was_empty(self):
self.object.get_next(self.timeout)

def test_returns_documents_in_order_provided(self):
self.object._config.documents = [{"order": 0}, {"order": 1}, {"order": 2}]
config = copy.deepcopy(self.CONFIG)
config["documents"] = [{"order": 0}, {"order": 1}, {"order": 2}]
self.object = Factory.create({"Test Instance Name": config})
for order in range(0, 3):
event, _ = self.object.get_next(self.timeout)
assert event.get("order") == order

def test_raises_exceptions_instead_of_returning_them_in_document(self):
self.object._config.documents = [{"order": 0}, DummyError, {"order": 1}]
config = copy.deepcopy(self.CONFIG)
config["documents"] = [{"order": 0}, DummyError, {"order": 1}]
self.object = Factory.create({"Test Instance Name": config})
event, _ = self.object.get_next(self.timeout)
assert event.get("order") == 0
with raises(DummyError):
Expand All @@ -39,15 +43,17 @@ def test_raises_exceptions_instead_of_returning_them_in_document(self):
assert event.get("order") == 1

def test_raises_exceptions_instead_of_returning_them(self):
self.object._config.documents = [BaseException]
config = copy.deepcopy(self.CONFIG)
config["documents"] = [BaseException]
self.object = Factory.create({"Test Instance Name": config})
with raises(BaseException):
self.object.get_next(self.timeout)

def test_repeat_documents_repeats_documents(self):
config = copy.deepcopy(self.CONFIG)
config["repeat_documents"] = True
config["documents"] = [{"order": 0}, {"order": 1}, {"order": 2}]
connector = Factory.create(configuration={"Test Instance Name": config})
connector._config.documents = [{"order": 0}, {"order": 1}, {"order": 2}]

for order in range(0, 9):
event, _ = connector.get_next(self.timeout)
Expand Down

0 comments on commit 0a4a809

Please sign in to comment.