예제 #1
0
 def test_repr(self):
     """
     The result of L{repr} when called with an instance of the type returned
     by L{trivialInput} is a string that mentions the symbol name and
     nothing else.
     """
     self.assertEqual("<Apple>", repr(trivialInput(Input.apple)()))
예제 #2
0
 def test_repr(self):
     """
     The result of L{repr} when called with an instance of the type returned
     by L{trivialInput} is a string that mentions the symbol name and
     nothing else.
     """
     self.assertEqual("<Apple>", repr(trivialInput(Input.apple)()))
예제 #3
0
 def test_illegalRichInput(self):
     """
     L{IFiniteStateMachine.receive} raises L{IllegalInput} if called with a
     rich input that doesn't map to a symbol in the input alphabet.
     """
     banana = trivialInput(MoreInput.banana)
     exc = self.assertRaises(IllegalInput, self.fsm.receive, banana())
     self.assertEqual((MoreInput.banana,), exc.args)
예제 #4
0
 def test_illegalRichInput(self):
     """
     L{IFiniteStateMachine.receive} raises L{IllegalInput} if called with a
     rich input that doesn't map to a symbol in the input alphabet.
     """
     banana = trivialInput(MoreInput.banana)
     exc = self.assertRaises(IllegalInput, self.fsm.receive, banana())
     self.assertEqual((MoreInput.banana, ), exc.args)
예제 #5
0
    def test_richInputInterface(self):
        """
        L{DoesNotImplement} is raised if a rich input type is given which does
        not implement the interface required by one of the outputs which can be
        produced when that input is received.
        """
        apple = trivialInput(Input.apple)
        transitions = TransitionTable()
        transitions = transitions.addTransition(State.amber, Input.apple,
                                                [Output.aardvark], State.amber)

        self.assertRaises(DoesNotImplement, constructFiniteStateMachine, Input,
                          Output, State, transitions, State.amber, [apple],
                          {Output.aardvark: IRequiredByAardvark}, NULL_WORLD)
예제 #6
0
    def test_richInputInterface(self):
        """
        L{DoesNotImplement} is raised if a rich input type is given which does
        not implement the interface required by one of the outputs which can be
        produced when that input is received.
        """
        apple = trivialInput(Input.apple)
        transitions = TransitionTable()
        transitions = transitions.addTransition(
            State.amber, Input.apple, [Output.aardvark], State.amber)

        self.assertRaises(
            DoesNotImplement,
            constructFiniteStateMachine,
            Input, Output, State, transitions,
            State.amber, [apple], {Output.aardvark: IRequiredByAardvark},
            NULL_WORLD)
예제 #7
0
파일: _loop.py 프로젝트: AlexRRR/flocker
class _Sleep(trivialInput(ConvergenceLoopInputs.SLEEP)):
    """
    Sleep for given number of seconds.

    :ivar float delay_seconds: How many seconds to sleep.
    """
    @classmethod
    def with_jitter(cls, delay_seconds):
        """
        Add some noise to the delay, so sleeps aren't exactly the same across
        all processes.

        :param delay_seconds: How many seconds to sleep approximately.

        :return: ``_Sleep`` with jitter added.
        """
        jitter = 1 + uniform(-0.2, 0.2)
        return cls(delay_seconds=delay_seconds * jitter)
예제 #8
0
파일: _loop.py 프로젝트: jongiddy/flocker
class _ClientStatusUpdate(trivialInput(ConvergenceLoopInputs.STATUS_UPDATE)):
    """
예제 #9
0
    },
    State.STOPPING: {
        Input.REQUEST_START: Transition([], State.STOP_CANCELLED),
        Input.REQUEST_STOP: Transition([], State.STOPPING),
        Input.INSTANCE_STOPPED: Transition([], State.IDLE),
        Input.STOP_FAILED: Transition([Output.STOP], State.STOPPING),
    },
    State.STOP_CANCELLED: {
        Input.REQUEST_START: Transition([], State.STOP_CANCELLED),
        Input.REQUEST_STOP: Transition([], State.STOPPING),
        Input.INSTANCE_STOPPED: Transition([Output.START], State.STARTING),
        Input.STOP_FAILED: Transition([], State.ACTIVE),
    },
})

RequestStart = trivialInput(Input.REQUEST_START)


@implementer(IRichInput)
@attributes(['instance_id', 'image_metadata', 'instance_metadata'])
class InstanceStarted(object):
    @staticmethod
    def symbol():
        return Input.INSTANCE_STARTED

StartFailed = trivialInput(Input.START_FAILED)
RequestStop = trivialInput(Input.REQUEST_STOP)
InstanceStopped = trivialInput(Input.INSTANCE_STOPPED)
StopFailed = trivialInput(Input.STOP_FAILED)

예제 #10
0
 def test_symbol(self):
     """
     The C{symbol} method of the object returned by L{trivialInput} returns
     the symbol passed in.
     """
     self.assertIs(Input.apple, trivialInput(Input.apple).symbol())
예제 #11
0
 def test_interface(self):
     """
     The type returned by L{trivialInput} implements L{IRichInput}.
     """
     self.assertTrue(verifyClass(IRichInput, trivialInput(Input.apple)))
예제 #12
0
 def test_interface(self):
     """
     The type returned by L{trivialInput} implements L{IRichInput}.
     """
     self.assertTrue(verifyClass(IRichInput, trivialInput(Input.apple)))
예제 #13
0
class Gravenstein(trivialInput(Input.apple)):
    # Conveniently, apples are approximately spherical.
    radius = 3
예제 #14
0
 def test_symbol(self):
     """
     The C{symbol} method of the object returned by L{trivialInput} returns
     the symbol passed in.
     """
     self.assertIs(Input.apple, trivialInput(Input.apple).symbol())
예제 #15
0
 def test_interfaceOnInstance(self):
     """
     The an instance of the object returned by L{trivialInput} provides
     L{IRichInput}.
     """
     self.assertTrue(verifyObject(IRichInput, trivialInput(Input.apple)()))
예제 #16
0
파일: _loop.py 프로젝트: jongiddy/flocker
class _ConnectedToControlService(
        trivialInput(ClusterStatusInputs.CONNECTED_TO_CONTROL_SERVICE)):
    """
예제 #17
0
파일: _loop.py 프로젝트: jongiddy/flocker
class _StatusUpdate(trivialInput(ClusterStatusInputs.STATUS_UPDATE)):
    """
예제 #18
0
 def test_interfaceOnInstance(self):
     """
     The an instance of the object returned by L{trivialInput} provides
     L{IRichInput}.
     """
     self.assertTrue(verifyObject(IRichInput, trivialInput(Input.apple)()))