當前位置: 首頁>>代碼示例>>Python>>正文


Python db.Message類代碼示例

本文整理匯總了Python中autopush.db.Message的典型用法代碼示例。如果您正苦於以下問題:Python Message類的具體用法?Python Message怎麽用?Python Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Message類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_register

    def test_register(self):
        chid = str(uuid.uuid4())
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)

        # Verify its in the db
        rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
        results = list(rows)
        assert len(results) == 1
開發者ID:lholmquist,項目名稱:autopush,代碼行數:10,代碼來源:test_db.py

示例2: test_message_delete_pagination

    def test_message_delete_pagination(self):
        def make_messages(channel_id, count):
            m = []
            t = self._nstime()
            ttl = int(time.time()) + 200
            for i in range(count):
                m.append((self.uaid, channel_id, str(uuid.uuid4()), ttl, {}, t + i))
            return m

        chid = str(uuid.uuid4())
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)

        # Shove 80 messages in
        for message_args in make_messages(chid, 80):
            message.store_message(*message_args)

        # Verify we can see them all
        all_messages = list(message.fetch_messages(self.uaid, limit=100))
        eq_(len(all_messages), 80)

        # Delete them all
        message.delete_messages_for_channel(self.uaid, chid)

        # Verify they're gone
        all_messages = list(message.fetch_messages(self.uaid, limit=100))
        eq_(len(all_messages), 0)
開發者ID:lholmquist,項目名稱:autopush,代碼行數:28,代碼來源:test_db.py

示例3: test_update_message_fail

    def test_update_message_fail(self):
        message = Message(get_rotating_message_table(), SinkMetrics)
        message.store_message(self.uaid, uuid.uuid4().hex, self._nstime(), str(uuid.uuid4()), {})
        u = message.table.connection.update_item = Mock()

        def raise_condition(*args, **kwargs):
            raise ConditionalCheckFailedException(None, None)

        u.side_effect = raise_condition
        b = message.update_message(self.uaid, uuid.uuid4().hex, self._nstime(), str(uuid.uuid4()), {})
        eq_(b, False)
開發者ID:lholmquist,項目名稱:autopush,代碼行數:11,代碼來源:test_db.py

示例4: test_message_delete_fail_condition

    def test_message_delete_fail_condition(self):
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())

        def raise_condition(*args, **kwargs):
            raise ConditionalCheckFailedException(None, None)

        message.table = Mock()
        message.table.delete_item.side_effect = raise_condition
        result = message.delete_message(uaid="asdf", channel_id="asdf", message_id="asdf", updateid="asdf")
        eq_(result, False)
開發者ID:lholmquist,項目名稱:autopush,代碼行數:11,代碼來源:test_db.py

示例5: test_save_channels

    def test_save_channels(self):
        chid = str(uuid.uuid4())
        chid2 = str(uuid.uuid4())
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)
        message.register_channel(self.uaid, chid2)

        exists, chans = message.all_channels(self.uaid)
        new_uaid = uuid.uuid4().hex
        message.save_channels(new_uaid, chans)
        _, new_chans = message.all_channels(new_uaid)
        eq_(chans, new_chans)
開發者ID:lholmquist,項目名稱:autopush,代碼行數:13,代碼來源:test_db.py

示例6: test_unregister

    def test_unregister(self):
        chid = str(uuid.uuid4())
        m = get_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)

        # Verify its in the db
        rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
        results = list(rows)
        assert(len(results) == 1)
        eq_(results[0]["chids"], set([chid]))

        message.unregister_channel(self.uaid, chid)

        # Verify its not in the db
        rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
        results = list(rows)
        assert(len(results) == 1)
        eq_(results[0]["chids"], set([]))
開發者ID:ncalexan,項目名稱:autopush,代碼行數:19,代碼來源:test_db.py

示例7: test_all_channels

    def test_all_channels(self):
        chid = str(uuid.uuid4())
        chid2 = str(uuid.uuid4())
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)
        message.register_channel(self.uaid, chid2)

        _, chans = message.all_channels(self.uaid)
        assert chid in chans
        assert chid2 in chans

        message.unregister_channel(self.uaid, chid2)
        _, chans = message.all_channels(self.uaid)
        assert chid2 not in chans
        assert chid in chans
開發者ID:lholmquist,項目名稱:autopush,代碼行數:16,代碼來源:test_db.py

示例8: test_unregister

    def test_unregister(self):
        chid = str(uuid.uuid4())
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)

        # Verify its in the db
        rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
        results = list(rows)
        assert len(results) == 1
        eq_(results[0]["chids"], set([chid]))

        message.unregister_channel(self.uaid, chid)

        # Verify its not in the db
        rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ")
        results = list(rows)
        assert len(results) == 1
        eq_(results[0]["chids"], set([]))

        # Test for the very unlikely case that there's no 'chid'
        m.connection.update_item = Mock()
        m.connection.update_item.return_value = {"Attributes": {"uaid": {"S": self.uaid}}, "ConsumedCapacityUnits": 0.5}
        r = message.unregister_channel(self.uaid, "test")
        eq_(r, False)
開發者ID:lholmquist,項目名稱:autopush,代碼行數:25,代碼來源:test_db.py

示例9: test_update_message

 def test_update_message(self):
     chid = uuid.uuid4().hex
     m = get_rotating_message_table()
     message = Message(m, SinkMetrics())
     data1 = str(uuid.uuid4())
     data2 = str(uuid.uuid4())
     time1 = self._nstime()
     time2 = self._nstime() + 100
     ttl = self._nstime() + 1000
     message.store_message(self.uaid, chid, time1, ttl, data1, {})
     message.update_message(self.uaid, chid, time2, ttl, data2, {})
     messages = list(message.fetch_messages(self.uaid))
     eq_(data2, messages[0]["#dd"])
開發者ID:lholmquist,項目名稱:autopush,代碼行數:13,代碼來源:test_db.py

示例10: test_delete_user

    def test_delete_user(self):
        chid = str(uuid.uuid4())
        chid2 = str(uuid.uuid4())
        m = get_rotating_message_table()
        message = Message(m, SinkMetrics())
        message.register_channel(self.uaid, chid)
        message.register_channel(self.uaid, chid2)

        data1 = str(uuid.uuid4())
        data2 = str(uuid.uuid4())
        ttl = int(time.time()) + 100
        time1, time2, time3 = self._nstime(), self._nstime(), self._nstime() + 1
        message.store_message(self.uaid, chid, time1, ttl, data1, {})
        message.store_message(self.uaid, chid2, time2, ttl, data2, {})
        message.store_message(self.uaid, chid2, time3, ttl, data1, {})

        message.delete_user(self.uaid)
        all_messages = list(message.fetch_messages(self.uaid))
        eq_(len(all_messages), 0)
開發者ID:lholmquist,項目名稱:autopush,代碼行數:19,代碼來源:test_db.py

示例11: test_all_channels_no_uaid

 def test_all_channels_no_uaid(self):
     m = get_rotating_message_table()
     message = Message(m, SinkMetrics())
     exists, chans = message.all_channels("asdf")
     assert chans == set([])
開發者ID:lholmquist,項目名稱:autopush,代碼行數:5,代碼來源:test_db.py

示例12: test_all_channels_no_uaid

 def test_all_channels_no_uaid(self):
     m = get_message_table()
     message = Message(m, SinkMetrics())
     assert(message.all_channels("asdf") == set([]))
開發者ID:ncalexan,項目名稱:autopush,代碼行數:4,代碼來源:test_db.py


注:本文中的autopush.db.Message類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。