In this example, we implement a simple publish-subscribe -scenario for Plone with an AMQP message broker like RabbitMQ:
Let there be a Plone site called Site A:
git checkout https://github.com/datakurre/pubsubannouncements.git Site_A
cd Site_A
python bootstrap
bin/buildout
source bin/rabbitmq-env
bin/rabbitmq-server
bin/instance fg
This Site A has a view called @@send-announcement with a custom HTML form for sending or clearing the announcement that should be shown also on all the other site.
Then, let there be other Plone sites, and let’s call one of them Site B:
git checkout https://github.com/datakurre/pubsubannouncements.git Site_B
cd Site_B
python bootstrap
bin/buildout instance:http-address=8081
bin/instance fg
Those sites should immediately act upon on the announcement messages sent by Site A. In this case by making those announcements visible for all the current users.
When we have at least one (and preferrebly at least the two) Plone instance up and running, we still need to log in to each of them and create the actual Plone site. For this example, we should always use Plone as the site id.
Finally, we should be able to try this out.
Given I'm logged in as an admin
When I open the announcement form
And I submit a test announcement
And I return to the front page
Then the page displays my test announcement.
Given I'm logged in as an admin
And I've sent a test announcement
When I open the announcement form
And I submit an empty announcement
And I return to the front page
Then the page no longer displays my test announcement.
Log in admin
Go to ${PLONE_URL}/@@send-announcement
Input text and validate form.widgets.message This is a test announcement!
Click button Send
Go to ${PLONE_URL}
Page should contain This is a test announcement!
Go to ${PLONE_URL}/@@send-announcement
Input text and validate form.widgets.message This is a test announcement!
Click button Send
Click button Send
Page should not contain This is a test announcement!
Logs the user into Plone with site owner name and password. The logged-in user will have Manager-role and all permissions.
Log in ${SITE_OWNER_NAME} ${SITE_OWNER_PASSWORD}
A helper keyword for setting text value of the located input field and checking that the value has been set.
This keyword should not be used directly, but only called the keyword Input text and validate.
Input text ${locator} ${text}
${value} = Get value ${locator}
Should be equal ${text} ${value}
A helper keyword accepting ${locator} and ${text} and setting text value of the located input field and checking that the value has been set.
Actually, this should not be needed. This was added when CI tests were failing randomly, because of not all login form fields were always filled (probably due to a slow CI server). The need for this might indicate an issue in Selenium2Library.
${timeout} = Get selenium timeout
Wait until keyword succeeds ${timeout} 0.5s Input text and validate once ${locator} ${text}
Goes to the Plone login form and Logs in the user with the given ${userid} and ${password}. The logged-in user will be left on the welcome page after the login.
Go to ${PLONE_URL}/login_form
Page should contain button Log in
Input text and validate __ac_name ${userid}
Input text and validate __ac_password ${password}
Click Button Log in
Page should not contain button Log in
This package is intended as a simple example on how to implement and test an instant publish-subscribe -scenario between multiple Plone sites using collective.zamqp.
This package is not intended to be used in production as such.