def test_baseservice_service_directory():
    """
    Base service tests for:
        - [x] name on init
        - [x] idle state on init
        - [x] started state on start()
        - [x] ready() alias for idle state
        - [x] stopped state on stop()
        - [x] idle state exception when service not in stopped state
        - [x] idle state on idle()
    :return:
    """

    name = "base-service-1"
    base = BaseService(name)
    assert base.name == name
    assert base.get_state() == BaseStates.Idle
    assert base.ready() is True  # ready == Idle

    greenlet = base.start()
    assert greenlet is not None
    assert base.get_state() == BaseStates.Started
    assert base.ready() is False

    # exception should be thrown if state is started
    # and asking service to make itself idle.
    try:
        base.idle()
    except IdleActionException as ex:
        assert ex is not None

    base.stop()
    assert base.get_state() == BaseStates.Stopped
    base.idle()  # should not throw this time
    assert base.get_state() == BaseStates.Idle
 def __init__(self, service):
     BaseService.__init__(self, "timer")
     self.service = service
 def __init__(self, name, loop_interval=.5):
     BaseService.__init__(self, name)
     self.register_child_stat(name)
     self.loop_interval = loop_interval
     self.ack = False
Example #4
0
 def __init__(self, name, request_spec, session=requests.Session()):
     BaseService.__init__(self, name)
     self.request_spec = request_spec
     self.machine = RequestMachine(session, request_spec)
Example #5
0
 def __init__(self, name, request_spec, session=requests.Session()):
     BaseService.__init__(self, name)
     self.request_spec = request_spec
     self.machine = RequestMachine(session, request_spec)
Example #6
0
 def __init__(self, name, loop_interval=.5):
     BaseService.__init__(self, name)
     self.register_child_stat(name)
     self.loop_interval = loop_interval
     self.ack = False