Add basic robot test setup and a first test.

This commit is contained in:
tisto 2014-05-02 13:22:08 +02:00
parent fa17c51a7b
commit f894d47d62
4 changed files with 115 additions and 2 deletions

View File

@ -1,11 +1,17 @@
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import applyProfile
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING
from plone.app.testing import IntegrationTesting from plone.app.testing import IntegrationTesting
from plone.app.testing import FunctionalTesting from plone.app.testing import FunctionalTesting
from plone.app.testing import PloneSandboxLayer
from plone.app.testing import applyProfile
from plone.testing import z2
from plone.registry.interfaces import IRegistry
from zope.component import queryUtility
from zope.configuration import xmlconfig from zope.configuration import xmlconfig
try: try:
@ -72,6 +78,16 @@ class PloneAppDiscussion(PloneSandboxLayer):
[], [],
) )
class PloneAppDiscussionRobot(PloneAppDiscussion):
def setUpPloneSite(self, portal):
registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
settings.globally_enabled = True
PLONE_APP_DISCUSSION_ROBOT_FIXTURE = PloneAppDiscussionRobot()
PLONE_APP_DISCUSSION_FIXTURE = PloneAppDiscussion() PLONE_APP_DISCUSSION_FIXTURE = PloneAppDiscussion()
PLONE_APP_DISCUSSION_INTEGRATION_TESTING = IntegrationTesting( PLONE_APP_DISCUSSION_INTEGRATION_TESTING = IntegrationTesting(
bases=(PLONE_APP_DISCUSSION_FIXTURE,), bases=(PLONE_APP_DISCUSSION_FIXTURE,),
@ -79,3 +95,10 @@ PLONE_APP_DISCUSSION_INTEGRATION_TESTING = IntegrationTesting(
PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING = FunctionalTesting( PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING = FunctionalTesting(
bases=(PLONE_APP_DISCUSSION_FIXTURE,), bases=(PLONE_APP_DISCUSSION_FIXTURE,),
name="PloneAppDiscussion:Functional") name="PloneAppDiscussion:Functional")
PLONE_APP_DISCUSSION_ROBOT_TESTING = FunctionalTesting(
bases=(
PLONE_APP_DISCUSSION_ROBOT_FIXTURE,
REMOTE_LIBRARY_ROBOT_TESTING
),
name="PloneAppDiscussion:Robot"
)

View File

@ -0,0 +1,62 @@
# bin/robot-server plone.app.discussion.testing.PLONE_APP_DISCUSSION_ROBOT_TESTING
# $ bin/robot src/plone.app.discussion/src/plone/app/discussion/tests/robot/test_discussion.robot
*** Settings ***
Resource plone/app/robotframework/selenium.robot
Library Remote ${PLONE_URL}/RobotRemote
Test Setup Open test browser
Test Teardown Close all browsers
*** Test Cases ***
Enable Discussion on Document
Given a logged-in Site Administrator
and a document
When I enable discussion on the document
Then I can see a comment form on the document
#Post Comment on Document
# Given a logged-in Site Administrator
# and a document with discussion enabled
# When I post a comment
# Then I can see the comment below the document
#Reply to comment on Document
# Given a logged-in Site Administrator
# and a document with discussion enabled
#Delete Comment
# Given a logged-in Site Administrator
# and a document with discussion enabled
*** Keywords ***
# Given
a logged-in Site Administrator
Enable autologin as Site Administrator
a document
Create content type=Document id=my-document title=My Document
# When
I enable discussion on the document
Go To ${PLONE_URL}/my-document/edit
Wait until page contains Settings
Click Link Settings
Wait until element is visible name=form.widgets.IAllowDiscussion.allow_discussion:list
Select From List name=form.widgets.IAllowDiscussion.allow_discussion:list True
Click Button Save
# Then
I can see a comment form on the document
Go To ${PLONE_URL}/my-document/view
Wait until page contains My Document
Page should contain Add comment
Page should contain element id=form-widgets-comment-text

View File

@ -0,0 +1,27 @@
from plone.app.discussion.testing import PLONE_APP_DISCUSSION_ROBOT_TESTING
from plone.app.testing import ROBOT_TEST_LEVEL
from plone.testing import layered
import os
import unittest
import robotsuite
def test_suite():
suite = unittest.TestSuite()
current_dir = os.path.abspath(os.path.dirname(__file__))
robot_dir = os.path.join(current_dir, 'robot')
robot_tests = [
os.path.join('robot', doc) for doc in
os.listdir(robot_dir) if doc.endswith('.robot') and
doc.startswith('test_')
]
for robot_test in robot_tests:
robottestsuite = robotsuite.RobotTestSuite(robot_test)
robottestsuite.level = ROBOT_TEST_LEVEL
suite.addTests([
layered(
robottestsuite,
layer=PLONE_APP_DISCUSSION_ROBOT_TESTING
),
])
return suite

View File

@ -53,6 +53,7 @@ setup(name='plone.app.discussion',
'test': [ 'test': [
'plone.app.testing', 'plone.app.testing',
'plone.app.contenttypes[test]', 'plone.app.contenttypes[test]',
'plone.app.robotframework[ride,reload,debug]',
] ]
}, },
entry_points=""" entry_points="""