from expects import expect, be
from doublex import Spy
from doublex_expects import have_been_called

from pysellus import integrations
from pysellus.integrations import on_failure


with description('the integrations module'):
    with context('exposes an `on_failure` decorator which'):
        with before.each:
            integrations.integrations = {}

        with after.each:
            integrations.integrations = {}

        with it('returns the decorated function as is'):
            decorated_function = Spy().decorated_function

            expect(on_failure('some_integration_name')(decorated_function)).to(be(decorated_function))

        with it('doesn\'t call the decorated function'):
            decorated_function = Spy().decorated_function

            on_failure('some_integration_name')(decorated_function)

            expect(decorated_function).to_not(have_been_called)

Add two basic tests for `on_failure`.
Add two basic tests for `on_failure`.
