# Path: grappa/engine.py
# class Engine(object):
#     """
#     Engine implements the test engine responsible of registering, storing and
#     running test operators.
#     """
# 
#     # globally store test operators by name
#     operators = {}
# 
#     def __init__(self):
#         self.keywords = []
#         self.assertions = []
# 
#     @staticmethod
#     def register(*operators):
#         """
#         Registers one or multiple operators in the test engine.
#         """
#         register_operators(*operators)
# 
#     @property
#     def empty(self):
#         return len(self.assertions) == 0
# 
#     def add_assertion(self, assertion):
#         self.assertions.append(assertion)
# 
#     def add_keyword(self, keyword):
#         self.keywords.append(keyword)
# 
#     def reverse(self):
#         self.assertions.reverse()
# 
#     def find_operator(self, name):
#         return self.operators.get(name)
# 
#     def run(self, ctx):
#         return Runner(self).run(ctx)
# 
#     def reset(self):
#         self.__init__()
# 
#     def reset_keywords(self):
#         self.keywords = []
# 
#     def clone(self):
#         engine = Engine()
#         engine.keywords = self.keywords[:]
#         engine.assertions = self.assertions[:]
#         return engine


import grappa
from grappa.engine import Engine


def test_plugin_api(should):
    grappa | should.be.a('module')
    grappa | should.have.property('use') > should.be.a('function')


def test_register_plugin_function(should):
    state = {'called': False}

    def plugin_stub(engine):
        engine | should.be.equal.to(Engine)
        engine | should.have.property('register') > should.be.a('function')
        state['called'] = True

    grappa.use(plugin_stub)
    state | should.be.have.key('called') > should.be.true


def test_register_plugin_method(should):
    state = {'called': False}

    class plugin_stub(object):
        @staticmethod
        def register(engine):

# Path: grappa/engine.py
# class Engine(object):
#     """
#     Engine implements the test engine responsible of registering, storing and
#     running test operators.
#     """
# 
#     # globally store test operators by name
#     operators = {}
# 
#     def __init__(self):
#         self.keywords = []
#         self.assertions = []
# 
#     @staticmethod
#     def register(*operators):
#         """
#         Registers one or multiple operators in the test engine.
#         """
#         register_operators(*operators)
# 
#     @property
#     def empty(self):
#         return len(self.assertions) == 0
# 
#     def add_assertion(self, assertion):
#         self.assertions.append(assertion)
# 
#     def add_keyword(self, keyword):
#         self.keywords.append(keyword)
# 
#     def reverse(self):
#         self.assertions.reverse()
# 
#     def find_operator(self, name):
#         return self.operators.get(name)
# 
#     def run(self, ctx):
#         return Runner(self).run(ctx)
# 
#     def reset(self):
#         self.__init__()
# 
#     def reset_keywords(self):
#         self.keywords = []
# 
#     def clone(self):
#         engine = Engine()
#         engine.keywords = self.keywords[:]
#         engine.assertions = self.assertions[:]
#         return engine


# Path: tests/plugin_test.py
import grappa
from grappa.engine import Engine



def test_plugin_api(should):
    grappa | should.be.a('module')
    grappa | should.have.property('use') > should.be.a('function')


def test_register_plugin_function(should):
    state = {'called': False}

    def plugin_stub(engine):
        engine | should.be.equal.to(Engine)
        engine | should.have.property('register') > should.be.a('function')
        state['called'] = True

    grappa.use(plugin_stub)
    state | should.be.have.key('called') > should.be.true


def test_register_plugin_method(should):
    state = {'called': False}

    class plugin_stub(object):
        @staticmethod
        def register(engine):

            engine | should.be.equal.to(Engine)