source: products/quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/tests/testWidget.py @ 2360

Last change on this file since 2360 was 2360, checked in by mylan, 14 years ago

Toggle trunk for plone4 release.
Plone-3 release moved to brances/plone3.

Merged revisions 3345-3351,3355-3359,3361-3370,3372-3390,3397 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.referencedatagridfield/branches/plone4

Fixed minor conflicts in:

  • ./setup.py
  • ./quintagroup/referencedatagridfield/configure.zcml

........

r3345 | mylan | 2010-05-13 15:51:53 +0300 (Thu, 13 May 2010) | 1 line


Update requirements: in setup.py, included its in configure.zcml

........

r3346 | mylan | 2010-05-13 17:42:07 +0300 (Thu, 13 May 2010) | 1 line


Added refdatagridbrowser_popup view with popup customization for the referencedatagridfield

........

r3347 | mylan | 2010-05-13 17:50:14 +0300 (Thu, 13 May 2010) | 1 line


Added and registered datagridref_popup named template for the ReferenceDataGridWidget?

........

r3348 | mylan | 2010-05-13 18:59:34 +0300 (Thu, 13 May 2010) | 1 line


Fix typo in named_template_adapter

........

r3349 | mylan | 2010-05-13 19:00:21 +0300 (Thu, 13 May 2010) | 1 line


Prevent breakage of datagridwidget_manipulators.pt

........

r3350 | mylan | 2010-05-13 20:01:59 +0300 (Thu, 13 May 2010) | 1 line


Initial reference popup integration

........

r3351 | mylan | 2010-05-13 22:05:47 +0300 (Thu, 13 May 2010) | 1 line


Update default referencebrowser javascript / datagrid field to popup work correctly for new added row

........

r3355 | mylan | 2010-05-14 17:21:23 +0300 (Fri, 14 May 2010) | 1 line


Fix reference browser url calculation on the view - pass additional paramters

........

r3356 | mylan | 2010-05-14 17:26:49 +0300 (Fri, 14 May 2010) | 1 line


Update datagridwidget_manipulators template for additional params pass to datagridref_popup view

........

r3357 | mylan | 2010-05-14 17:27:59 +0300 (Fri, 14 May 2010) | 1 line


Remove order_idx from the additional parmeters - it will be calulated with jQuery

........

r3358 | mylan | 2010-05-14 17:29:20 +0300 (Fri, 14 May 2010) | 1 line


Updated jQuery processor on UID adding

........

r3359 | mylan | 2010-05-14 17:31:54 +0300 (Fri, 14 May 2010) | 1 line


Added focus and blur event-handlers to referencedatagridwidget javascripts

........

r3361 | mylan | 2010-05-17 18:08:44 +0300 (Mon, 17 May 2010) | 1 line


Fixed all overlays bindings to same target issue

........

r3362 | mylan | 2010-05-17 18:29:07 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3363 | mylan | 2010-05-17 18:29:51 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3364 | mylan | 2010-05-17 18:35:25 +0300 (Mon, 17 May 2010) | 1 line


Fixed link, title and uid data set in refbrowser_setReference

........

r3365 | mylan | 2010-05-17 18:38:15 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3366 | mylan | 2010-05-17 18:43:18 +0300 (Mon, 17 May 2010) | 1 line


Fix addReferenceDataGridRowAfter newly added method of dataGridFieldFunctions

........

r3367 | mylan | 2010-05-17 18:46:10 +0300 (Mon, 17 May 2010) | 1 line


Implemented addReferenceDataGridRowAfter method of dataGridFieldFunctions object

........

r3368 | mylan | 2010-05-17 18:47:22 +0300 (Mon, 17 May 2010) | 1 line


Override updateOrderIndex method of dataGridFieldFunctions

........

r3369 | mylan | 2010-05-17 19:14:01 +0300 (Mon, 17 May 2010) | 1 line


Fixed styles toggling on title column edition

........

r3370 | mylan | 2010-05-17 20:35:10 +0300 (Mon, 17 May 2010) | 1 line


Little clean-up

........

r3372 | mylan | 2010-05-18 19:02:12 +0300 (Tue, 18 May 2010) | 1 line


Fix Deprication warning for plone4 consider importing

........

r3373 | mylan | 2010-05-18 19:04:12 +0300 (Tue, 18 May 2010) | 1 line


Added base tests structure, move tests into the tests package

........

r3374 | mylan | 2010-05-18 19:04:51 +0300 (Tue, 18 May 2010) | 1 line


Added installation tests

........

r3375 | mylan | 2010-05-18 20:08:00 +0300 (Tue, 18 May 2010) | 1 line


Fixed package installation, updated demo content creation to MixIn? class

........

r3376 | mylan | 2010-05-18 22:20:41 +0300 (Tue, 18 May 2010) | 1 line


Added basic field test

........

r3377 | mylan | 2010-05-18 23:29:24 +0300 (Tue, 18 May 2010) | 1 line


Added test for link, uid, title for the field

........

r3378 | mylan | 2010-05-19 10:54:46 +0300 (Wed, 19 May 2010) | 1 line


Prevent changing security manager on tested content adding

........

r3379 | mylan | 2010-05-19 13:58:29 +0300 (Wed, 19 May 2010) | 1 line


Added tests for possible bugs in field processing

........

r3380 | mylan | 2010-05-19 13:58:54 +0300 (Wed, 19 May 2010) | 1 line


Updated testing content creation

........

r3381 | mylan | 2010-05-19 13:59:49 +0300 (Wed, 19 May 2010) | 1 line


Simplify field name for example content type

........

r3382 | mylan | 2010-05-19 14:01:16 +0300 (Wed, 19 May 2010) | 1 line


Fixed bug on getting data for uninitialized field

........

r3383 | mylan | 2010-05-19 15:22:37 +0300 (Wed, 19 May 2010) | 1 line


Added tests for widget in view mode

........

r3384 | mylan | 2010-05-19 16:47:06 +0300 (Wed, 19 May 2010) | 1 line


Update comments for TestWidgetView?, some code cleanup

........

r3385 | mylan | 2010-05-19 17:02:29 +0300 (Wed, 19 May 2010) | 1 line


Added TestWidgetEditPresence? tests for presence of columns and buttons in edit mode of the widget

........

r3386 | mylan | 2010-05-19 18:00:01 +0300 (Wed, 19 May 2010) | 1 line


Remove records with links to unexistent objects on getting data from the field

........

r3387 | mylan | 2010-05-19 18:13:57 +0300 (Wed, 19 May 2010) | 1 line


Minor changes

........

r3388 | mylan | 2010-05-19 18:14:42 +0300 (Wed, 19 May 2010) | 1 line


Added tests popup related adapters registration

........

r3389 | mylan | 2010-05-19 19:10:49 +0300 (Wed, 19 May 2010) | 1 line


Added tests for pupup related staff in edit mode of ReferenceDataGridWidget?

........

r3390 | mylan | 2010-05-19 19:12:06 +0300 (Wed, 19 May 2010) | 1 line


Added tests of widget resources

........

r3397 | mylan | 2010-05-19 21:02:51 +0300 (Wed, 19 May 2010) | 1 line


Added MANIFEST.in, updated author in package information

........

  • Property svn:eol-style set to native
File size: 6.0 KB
Line 
1import re
2import unittest
3
4from Products.PloneTestCase.PloneTestCase import portal_owner
5from Products.PloneTestCase.PloneTestCase import default_password
6
7from quintagroup.referencedatagridfield.tests.base import TestCase
8from quintagroup.referencedatagridfield.tests.base import FunctionalTestCase
9from quintagroup.referencedatagridfield import ReferenceDataGridWidget
10
11
12class TestWidgetView(FunctionalTestCase):
13    """ ReferenceDataGridWidget unit tests """
14
15    def afterSetUp(self):
16        self.loginAsPortalOwner()
17        # Prevent section links
18        sp = self.portal.portal_properties.site_properties
19        sp._updateProperty("disable_nonfolderish_sections", True)
20        # Prepare testing data and data for functional test
21        self.createDemo(wfaction="publish")
22        self.demo_path = "/" + self.demo.absolute_url(1)
23        self.basic_auth = ':'.join((portal_owner,default_password))
24        # Regexp for getting links
25        self.relink = re.compile("<a\s+[^>]*?href=\"(.*?)\"[^>]*?>\s*(.*?)\s*</a>",
26                                 re.I|re.S|re.M)
27
28    def test_LinkDefaultTitle(self):
29        self.demo.edit(demo_rdgf=[{"link": "http://google.com"}])
30        html = self.publish(self.demo_path, self.basic_auth).getBody()
31        links = dict(self.relink.findall(html))
32       
33        self.assertEqual(links.has_key("http://google.com"), True)
34        self.assertEqual("http://google.com" in links["http://google.com"], True)
35 
36    def test_LinkCustomTitle(self):
37        self.demo.edit(demo_rdgf=[{"link": "http://google.com", "title": "Google"}])
38        html = self.publish(self.demo_path, self.basic_auth).getBody()
39        links = dict(self.relink.findall(html))
40       
41        self.assertEqual(links.has_key("http://google.com"), True)
42        self.assertEqual("Google" in links["http://google.com"], True)
43 
44    def test_UIDDefaultTitle(self):
45        data = [{"uid": self.doc.UID(), "link": self.doc.absolute_url(1)}]
46        self.demo.edit(demo_rdgf=data)
47        html = self.publish(self.demo_path, self.basic_auth).getBody()
48        links = dict(self.relink.findall(html))
49
50        doc_url = self.doc.absolute_url()
51        doc_title = self.doc.Title()
52        self.assertEqual(links.has_key(doc_url), True)
53        self.assertEqual(doc_title in links[doc_url], True)
54
55    def test_UIDCustomTitle(self):
56        data = [{"uid": self.doc.UID(), "link": self.doc.absolute_url(1),
57                 "title": "Custom Title"},]
58        self.demo.edit(demo_rdgf=data)
59        html = self.publish(self.demo_path, self.basic_auth).getBody()
60        links = dict(self.relink.findall(html))
61
62        doc_url = self.doc.absolute_url()
63        self.assertEqual(links.has_key(doc_url), True)
64        self.assertEqual("Custom Title" in links[doc_url], True)
65
66    def test_LinksOrder(self):
67        relink = re.compile("<a\s+[^>]*?href=\"(.*?)\"[^>]*?>", re.I|re.S)
68        data = [{"link": "http://google.com"},
69                {"uid": self.doc.UID(), "link": self.doc.absolute_url(1)}]
70        # First check in one order
71        self.demo.edit(demo_rdgf=data)
72        html = self.publish(self.demo_path, self.basic_auth).getBody()
73        links = relink.findall(html)
74        idx1 = links.index("http://google.com")
75        idx2 = links.index(self.doc.absolute_url())
76        self.assertEqual( idx1 < idx2, True)
77        # Now reverse rows order
78        data.reverse()
79        self.demo.edit(demo_rdgf=data)
80        html = self.publish(self.demo_path, self.basic_auth).getBody()
81        links = relink.findall(html)
82        idx1 = links.index("http://google.com")
83        idx2 = links.index(self.doc.absolute_url())
84        self.assertEqual( idx1 > idx2, True)
85       
86
87class TestWidgetEditPresence(FunctionalTestCase):
88    """ Test presence of columns and button
89        in edit mode of ReferenceDataGridWidget.
90    """
91
92    def afterSetUp(self):
93        self.loginAsPortalOwner()
94        # Prepare test data
95        self.createDemo()
96        self.demo.edit(demo_rdgf=[{"link": "http://google.com"}])
97        # Prepare html for test edit form
98        edit_path = "/%s/edit" % self.demo.absolute_url(1)
99        basic_auth = ':'.join((portal_owner,default_password))
100        self.html = self.publish(edit_path, basic_auth).getBody()
101
102    def test_columnsPresence(self):
103        # Get ReferenceDataGridField field inputs without hidden template row for add new data
104        reinput = re.compile("<input\s+([^>]*?name=\"demo_rdgf\.(.*?):records\"[^>]*?)>", re.I|re.S)
105        inputs = dict([(v,k) for k,v in reinput.findall(self.html) if not "demo_rdgf_new" in k])
106        # Title and Link columns is visible
107        self.assertEqual('type="text"' in inputs["title"], True)
108        self.assertEqual('type="text"' in inputs["link"], True)
109        # UID column is hidden
110        self.assertEqual('type="hidden"' in inputs["uid"], True)
111
112    def test_addButtonPresence(self):
113        # Button for adding reference also must present
114        rebutt = re.compile("<input\s+[^>]*type=\"button\"\s*[^>]*>", re.I|re.S)
115        buttons = filter(lambda k:not "_new" in k, rebutt.findall(self.html))
116        # Add... button must present
117        self.assertEqual('value="Add..."' in buttons[0], True)
118
119
120class TestWidgetResources(TestCase):
121    """Tests of widget resources."""
122
123    def afterSetUp(self):
124        self.widget_props = ReferenceDataGridWidget._properties
125        self.rdgw_skin_ids = self.portal.portal_skins.referencedatagridfield.objectIds()
126
127    def test_helperJS(self):
128        helper_js = self.widget_props.get("helper_js", "")
129        self.assertEqual("referencedatagridwidget.js" in helper_js, True)
130        self.assertEqual("referencedatagridwidget.js" in self.rdgw_skin_ids, True)
131
132    def test_helperCSS(self):
133        helper_css = self.widget_props.get("helper_css", "")
134        self.assertEqual("referencedatagridwidget.css" in helper_css, True)
135        self.assertEqual("referencedatagridwidget.css" in self.rdgw_skin_ids, True)
136
137
138def test_suite():
139    return unittest.TestSuite([
140        unittest.makeSuite(TestWidgetView),
141        unittest.makeSuite(TestWidgetResources),
142        unittest.makeSuite(TestWidgetEditPresence),
143        ])
Note: See TracBrowser for help on using the repository browser.