Skip to content

Commit

Permalink
Adding tests for invalid callback function combination
Browse files Browse the repository at this point in the history
  • Loading branch information
chadgates committed May 4, 2024
1 parent 29af788 commit 894c087
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pyas2lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,47 @@ def test_invalid_message_id_length_raises_error(self):
in str(excinfo.value)
)

def test_invalid_cb_function_passed(self):
"""Checking allowed combination of CB functions"""

# Create AS2 message and parse with wrong combination of callback functions

as2_message = as2.Message()
with pytest.raises(
TypeError,
match="Incorrect arguments passed: either find_org_cb and find_partner_cb "
"or only find_org_partner_cb must be passed.",
):

_, _, _ = as2_message.parse(
"abc",
find_org_partner_cb=self.find_org_partner,
find_partner_cb=self.find_partner,
)

with pytest.raises(
TypeError,
match="Incorrect arguments passed: either find_org_cb and find_partner_cb "
"or only find_org_partner_cb must be passed.",
):
_, _, _ = as2_message.parse(
"abc",
find_org_partner_cb=self.find_org_partner,
find_org_cb=self.find_org,
)

with pytest.raises(
TypeError,
match="Incorrect arguments passed: either find_org_cb and find_partner_cb "
"or only find_org_partner_cb must be passed.",
):
_, _, _ = as2_message.parse(
"abc",
find_org_partner_cb=self.find_org_partner,
find_org_cb=self.find_org,
find_partner_cb=self.find_partner,
)

def find_org(self, as2_id):
return self.org

Expand Down

0 comments on commit 894c087

Please sign in to comment.