def test_session_on_behalf_prevent_reentrant_usage(self): self.setup_on_behalf_of() with pytest.raises(Exception) as excinfo: with currencycloud.on_behalf_of( 'c6ece846-6df1-461d-acaa-b42a6aa74045'): # noqa with currencycloud.on_behalf_of( 'f57b2d33-652c-4589-a8ff-7762add2706d'): # noqa raise Exception('Should raise exception') assert '#on_behalf_of has already been set' in str(excinfo.value)
def test_session_on_behalf_of_sets_removes_value(self): self.setup_on_behalf_of() with currencycloud.on_behalf_of( 'c6ece846-6df1-461d-acaa-b42a6aa74045'): # noqa assert currencycloud.session( ).on_behalf_of == 'c6ece846-6df1-461d-acaa-b42a6aa74045' assert currencycloud.session().on_behalf_of is None
def test_session_on_behalf_invalid_contact_id(self): self.setup_on_behalf_of() with pytest.raises(Exception) as excinfo: with currencycloud.on_behalf_of('Alessandro Iob'): raise Exception('Should raise exception') assert 'contact_id for on_behalf_of is not a valid UUID' in str( excinfo.value)
def test_session_on_behalf_removes_value_on_error(self): self.setup_on_behalf_of() with pytest.raises(Exception) as excinfo: with currencycloud.on_behalf_of( 'c6ece846-6df1-461d-acaa-b42a6aa74045'): # noqa assert currencycloud.session( ).on_behalf_of == 'c6ece846-6df1-461d-acaa-b42a6aa74045' raise Exception('Completed Expected error') assert 'Completed Expected error' in str(excinfo.value) assert currencycloud.session().on_behalf_of is None