def test_message_producer_send(self):
        # given
        EVENT_TYPE = "create_user"
        self.ps.subscribe(EVENT_TYPE)
        # when
        message_producer = MessageProducer()
        event = DomainEventImpl("v1")
        notification = Notification(notification_id=1,
                                    event=event,
                                    type_name=EVENT_TYPE,
                                    version="v1")
        # when
        # sleep for 0.5 sec to ensure successfully subscribe topic
        time.sleep(0.5)
        message_producer.send(notification)

        # then
        self.ps.get_message()  # first message is channel message

        @retry(stop=stop_after_delay(10),
               wait=wait_exponential(multiplier=1, min=1, max=2))
        def retry_get_message():
            message = self.ps.get_message()
            if message is None or message['type'] is 'subscribe':
                raise Exception(
                    "message is None or type is subscribe, retry...")
            # then
            result = pickle.loads(message['data'])
            self.assertEqual(result, event)

        retry_get_message()
    def test_properties(self):
        event = DomainEventImpl("v1")
        noti = Notification(notification_id=1,
                            event=event,
                            type_name="create_user",
                            version="v1")

        self.assertEqual(noti.notification_id, 1)
        self.assertEqual(noti.event, event)
        self.assertEqual(noti.type_name, "create_user")
        self.assertEqual(noti.version, "v1")
        self.assertIsNotNone(noti.occurred_on)
Ejemplo n.º 3
0
    def awakeFromNib(self):
        def onGrowlClick():
            self.applicationRef.unhide()
            self.cbxInput.becomeFirstResponder()

        self.notification = Notification(onGrowlClick)
        self.initControls()
        self.initWindow()
        self.readCounters()
        self._timer = (
            NSTimer.
            scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(
                userPrefs.timerInterval, self, self.timerFunction, None, True))