Пример #1
0
    def testViewletIsRendered(self):
        context = self.layer["portal"]
        request = self.layer["request"]

        from zope.interface import alsoProvides
        from z3c.form.interfaces import IFormLayer
        alsoProvides(request, IFormLayer)

        from pubsubannouncements.forms import AnnouncementForm
        form = AnnouncementForm(context, request)
        request.form = {
            "form.widgets.message": "This is a test announcement!",
            "form.buttons.send": "Send",
        }
        form.update()

        runAsyncTest(self._testAnonymousQueueIsDeclared)

        import transaction
        transaction.commit()

        runAsyncTest(self._testViewletIsRendered)
    def testFolderCreation(self):
        def untilDeclared():
            self.assertIn(
                'my.queue\t0',
                self.layer['rabbitctl']('list_queues')[0].split('\n')
            )
        runAsyncTest(untilDeclared)

        def noFolder():
            self.layer['portal']._p_jar.sync()
            self.assertNotIn('test-folder', self.layer['portal'].objectIds())

        noFolder()  # No folder before dispatch

        producer = getUtility(IProducer, name='my.queue')
        producer.register()  # register for transaction
        producer.publish('Hello World!')

        def notPublished():
            self.assertNotIn(
                'my.queue\t1',
                self.layer['rabbitctl']('list_queues')[0].split('\n')
            )

        runAsyncTest(notPublished)

        transaction.commit()

        def untilPublished():
            self.assertIn(
                'my.queue\t1',
                self.layer['rabbitctl']('list_queues')[0].split('\n')
            )
        runAsyncTest(untilPublished)

        def untilConsumed():
            self.assertIn(
                'my.queue\t0',
                self.layer['rabbitctl']('list_queues')[0].split('\n')
            )
        runAsyncTest(untilConsumed, loop_count=10)

        self.layer['portal']._p_jar.sync()
        self.assertIn('test-folder', self.layer['portal'].objectIds())

        self.assertEqual(
            self.layer['portal']['test-folder'].title, u'Hello World!')
        self.assertIn(
            TEST_USER_ID, self.layer['portal']['test-folder'].Creator())
Пример #3
0
    def testFolderCreation(self):
        def untilDeclared():
            self.assertIn(
                'my.queue\t0',
                self.layer['rabbitctl']('list_queues')[0].split('\n'))

        runAsyncTest(untilDeclared)

        def noFolder():
            self.layer['portal']._p_jar.sync()
            self.assertNotIn('test-folder', self.layer['portal'].objectIds())

        noFolder()  # No folder before dispatch

        producer = getUtility(IProducer, name='my.queue')
        producer.register()  # register for transaction
        producer.publish('Hello World!')

        def notPublished():
            self.assertNotIn(
                'my.queue\t1',
                self.layer['rabbitctl']('list_queues')[0].split('\n'))

        runAsyncTest(notPublished)

        transaction.commit()

        def untilPublished():
            self.assertIn(
                'my.queue\t1',
                self.layer['rabbitctl']('list_queues')[0].split('\n'))

        runAsyncTest(untilPublished)

        def untilConsumed():
            self.assertIn(
                'my.queue\t0',
                self.layer['rabbitctl']('list_queues')[0].split('\n'))

        runAsyncTest(untilConsumed, loop_count=10)

        self.layer['portal']._p_jar.sync()
        self.assertIn('test-folder', self.layer['portal'].objectIds())

        self.assertEqual(self.layer['portal']['test-folder'].title,
                         u'Hello World!')
        self.assertIn(TEST_USER_ID,
                      self.layer['portal']['test-folder'].Creator())
Пример #4
0
    def testPublishToQueueAndConsumeIt(self):
        runAsyncTest(self._testDeclareQueue)

        from zope.component import getUtility
        from collective.zamqp.interfaces import IProducer
        producer = getUtility(IProducer, name="my.queue")
        producer.publish("Hello world!")

        runAsyncTest(self._testPublishToQueue)
        runAsyncTest(self._testPublishToQueueAndConsumeIt)
Пример #5
0
    def testPublishToQueueAndConsumeIt(self):
        runAsyncTest(self._testDeclareQueue)

        from zope.component import getUtility
        from collective.zamqp.interfaces import IProducer
        producer = getUtility(IProducer, name="my.queue")
        producer.publish("Hello world!")

        runAsyncTest(self._testPublishToQueue)
        runAsyncTest(self._testPublishToQueueAndConsumeIt, loop_count=10)
    def testPublishToQueueAndConsumeIt(self):
        runAsyncTest(self._testDeclareQueue)

        from zope.component import getUtility
        from collective.zamqp.interfaces import IProducer
        producer = getUtility(IProducer, name="my.picklequeue")
        producer.publish({"key": "value"})

        runAsyncTest(self._testPublishToQueue)
        runAsyncTest(self._testPublishToQueueAndConsumeIt)
        self.l.check(
            ('c.zamqp.tests', 'INFO', "<BasicProperties(['delivery_mode=2', "
             "'content_type=application/x-python-serialize'])>"),
            ('c.zamqp.tests', 'INFO', "{'key': 'value'}"),
            ('c.zamqp.tests', 'INFO', "<type 'dict'>"))
    def testPublishToQueueAndConsumeIt(self):
        runAsyncTest(self._testDeclareQueue)

        from zope.component import getUtility
        from collective.zamqp.interfaces import IProducer
        producer = getUtility(IProducer, name="my.picklequeue")
        producer.publish({"key": "value"})

        runAsyncTest(self._testPublishToQueue)
        runAsyncTest(self._testPublishToQueueAndConsumeIt)
        self.l.check(
            ('c.zamqp.tests', 'INFO',
             "<BasicProperties(['delivery_mode=2', "
             "'content_type=application/x-python-serialize'])>"),
            ('c.zamqp.tests', 'INFO', "{'key': 'value'}"),
            ('c.zamqp.tests', 'INFO', "<type 'dict'>")
        )
 def testDeclareQueueAgain(self):
     runAsyncTest(self._testDeclareQueueAgain)
 def testDeclareQueue(self):
     runAsyncTest(self._testDeclareQueue)
 def testDeclareQueueAgain(self):
     runAsyncTest(self._testDeclareQueueAgain)
 def testDeclareQueue(self):
     runAsyncTest(self._testDeclareQueue)
Пример #12
0
 def testAnonymousQueueIsDeclared(self):
     runAsyncTest(self._testAnonymousQueueIsDeclared)
Пример #13
0
 def testExchangeIsDeclared(self):
     runAsyncTest(self._testExchangeIsDeclared)
Пример #14
0
 def testNoQueues(self):
     runAsyncTest(self._testNoQueues)
Пример #15
0
 def testNoQueues(self):
     runAsyncTest(self._testNoQueues)