diff --git a/pyas2lib/tests/test_basic.py b/pyas2lib/tests/test_basic.py index 87f09cb..e1dc83a 100644 --- a/pyas2lib/tests/test_basic.py +++ b/pyas2lib/tests/test_basic.py @@ -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