Ejemplo n.º 1
0
    def test_SpecifyThatTriggersCanBeUpdated(self):
        # arrange
        BaseEntity.ResetNextValidId()
        trigger = Trigger(1)
        trigger.Update = mock.Mock()
        triggerSystem = TriggerSystem()
        triggerSystem.Register(trigger)

        # act
        triggerSystem.UpdateTriggers()

        # assert
        trigger.Update.assert_called()
Ejemplo n.º 2
0
    def test_SpecifyThatTriggersCanBeRegisteredAndCleared(self):
        BaseEntity.ResetNextValidId()
        triggerSystem = TriggerSystem()

        self.assertEqual(0, len(triggerSystem.GetTriggers()), "len 1")

        triggerSystem.Register(Trigger(1))
        triggerSystem.Register(Trigger(2))

        self.assertEqual(2, len(triggerSystem.GetTriggers()), "len 2")

        triggerSystem.Clear()

        self.assertEqual(0, len(triggerSystem.GetTriggers()), "len 3")
Ejemplo n.º 3
0
    def test_SpecifyThatNextValidIdCanBeReset(self):
        newBaseEntity = None

        # arrange
        for i in range(0, 5):
            newBaseEntity = BaseEntity(i)

        # assert
        self.assertEqual(newBaseEntity.Id, 4)
        self.assertEqual(BaseEntity.GetNextValidId(), 5)

        # act
        BaseEntity.ResetNextValidId()

        # assert
        self.assertEqual(BaseEntity.GetNextValidId(), 0)
Ejemplo n.º 4
0
    def __init__(self, firestoreClient, entities):

        self._firestoreClient = firestoreClient
        self._entities = entities
        self._actionMap = {}

        BaseEntity.ResetNextValidId()
        TelegramDispatcher().Clear()

        for entity in self._entities:
            EntityManager.RegisterEntity(entity)
            self._actionMap.update(entity.ActionMap)

        transactionsRef = self._firestoreClient \
            .collection(DIALOG_FLOW_TRANSACTIONS_URL) \
            .where('status', '==', 'UNPROCESSED')

        self._transactionListener = transactionsRef.on_snapshot(self._processRequests)
Ejemplo n.º 5
0
 def CreateTestTrigger():
     BaseEntity.ResetNextValidId()
     return Trigger(1)
 def tearDown(self):
     EntityManager.Reset()
     BaseEntity.ResetNextValidId()
Ejemplo n.º 7
0
 def CreateTriggerLimitedLifetime():
     BaseEntity.ResetNextValidId()
     return TriggerLimitedLifetime(10)
Ejemplo n.º 8
0
 def tearDown(self):
     BaseEntity.ResetNextValidId()
    def CreateStateMachine(self):
        BaseEntity.ResetNextValidId()
        entity = BaseEntity(self.EntityId)
        stateMachine = StateMachine(entity)

        return stateMachine
Ejemplo n.º 10
0
 def CreateUser():
     BaseEntity.ResetNextValidId()
     return User(entityId=1)
 def tearDown(self):
     EntityManager.Reset()
     BaseEntity.ResetNextValidId()
     TelegramDispatcher().Clear()
Ejemplo n.º 12
0
 def CreateTestBot():
     BaseEntity.ResetNextValidId()
     return TestBot(1)
 def CreateTriggerRespawning():
     BaseEntity.ResetNextValidId()
     triggerRespawning = TriggerRespawning(1)
     triggerRespawning.SetRespawnDelay(10)
     return triggerRespawning