[test] port to cubicweb 3.19
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 25 Jul 2014 12:22:08 +0200
changeset 334 9d38aa2bf1c9
parent 332 f58e774d65af
child 335 b0daa452d255
[test] port to cubicweb 3.19
__pkginfo__.py
cubicweb-blog.spec
debian/control
test/unittest_blog.py
--- a/__pkginfo__.py	Wed Feb 19 10:15:08 2014 +0100
+++ b/__pkginfo__.py	Fri Jul 25 12:22:08 2014 +0200
@@ -19,7 +19,7 @@
     'Programming Language :: JavaScript',
     ]
 
-__depends__ = {'cubicweb': '>= 3.17.0'}
+__depends__ = {'cubicweb': '>= 3.19.0'}
 __recommends__ = {'cubicweb-tag': None,
                   'cubicweb-preview': None,
                   'cubicweb-comment': '>= 1.6.3',
--- a/cubicweb-blog.spec	Wed Feb 19 10:15:08 2014 +0100
+++ b/cubicweb-blog.spec	Fri Jul 25 12:22:08 2014 +0200
@@ -20,7 +20,7 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 
 BuildRequires:  %{python} %{python}-setuptools
-Requires:       cubicweb >= 3.17.0
+Requires:       cubicweb >= 3.19.0
 
 %description
 blogging component for the CubicWeb framework
--- a/debian/control	Wed Feb 19 10:15:08 2014 +0100
+++ b/debian/control	Fri Jul 25 12:22:08 2014 +0200
@@ -9,7 +9,7 @@
 
 Package: cubicweb-blog
 Architecture: all
-Depends: cubicweb-common (>= 3.17.0)
+Depends: cubicweb-common (>= 3.19.0)
 Suggests: cubicweb-comment (>= 1.6.3), cubicweb-tag, cubicweb-sioc, python-feedparser, python-rdflib
 Recommends: cubicweb-preview, cubicweb-seo
 Description: blog component for the CubicWeb framework
--- a/test/unittest_blog.py	Wed Feb 19 10:15:08 2014 +0100
+++ b/test/unittest_blog.py	Fri Jul 25 12:22:08 2014 +0200
@@ -8,32 +8,32 @@
     """test blog specific behaviours"""
 
     def test_notifications(self):
-        req = self.request()
-        cubicweb_blog = req.create_entity('Blog', title=u'cubicweb',
-                                          description=u"cubicweb c'est beau")
-        blog_entry_1 = req.create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
-        blog_entry_1.set_relations(entry_of=cubicweb_blog)
-        blog_entry_2 = req.create_entity('BlogEntry', title=u"yes",  content=u"cubicweb yes")
-        blog_entry_2.set_relations(entry_of=cubicweb_blog)
-        self.assertEqual(len(MAILBOX), 0)
-        self.commit()
-        self.assertEqual(len(MAILBOX), 0)
-        blog_entry_1.cw_adapt_to('IWorkflowable').fire_transition('publish')
-        self.commit()
-        self.assertEqual(len(MAILBOX), 1)
-        mail = MAILBOX[0]
-        self.assertEqual(mail.subject, '[data] hop')
-        blog_entry_2.cw_adapt_to('IWorkflowable').fire_transition('publish')
-        self.commit()
-        self.assertEqual(len(MAILBOX), 2)
-        mail = MAILBOX[1]
-        self.assertEqual(mail.subject, '[data] yes')
+        with self.admin_access.client_cnx() as cnx:
+            cubicweb_blog = cnx.create_entity('Blog', title=u'cubicweb',
+                                              description=u"cubicweb c'est beau")
+            blog_entry_1 = cnx.create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
+            blog_entry_1.cw_set(entry_of=cubicweb_blog)
+            blog_entry_2 = cnx.create_entity('BlogEntry', title=u"yes",  content=u"cubicweb yes")
+            blog_entry_2.cw_set(entry_of=cubicweb_blog)
+            self.assertEqual(len(MAILBOX), 0)
+            cnx.commit()
+            self.assertEqual(len(MAILBOX), 0)
+            blog_entry_1.cw_adapt_to('IWorkflowable').fire_transition('publish')
+            cnx.commit()
+            self.assertEqual(len(MAILBOX), 1)
+            mail = MAILBOX[0]
+            self.assertEqual(mail.subject, '[data] hop')
+            blog_entry_2.cw_adapt_to('IWorkflowable').fire_transition('publish')
+            cnx.commit()
+            self.assertEqual(len(MAILBOX), 2)
+            mail = MAILBOX[1]
+            self.assertEqual(mail.subject, '[data] yes')
 
     def test_rss(self):
-        req = self.request()
-        cubicweb_blog = req.create_entity('Blog', title=u'cubicweb',
-                                          description=u"cubicweb c'est beau")
-        content = u"""
+        with self.admin_access.client_cnx() as cnx:
+            cubicweb_blog = cnx.create_entity('Blog', title=u'cubicweb',
+                                              description=u"cubicweb c'est beau")
+            content = u"""
 <style> toto </style> tutu <style class=macin> toto
 </style>
 tutu
@@ -43,27 +43,27 @@
 <tag>tutu</tag>
 
 """
-        blog_entry_1 = req.create_entity('BlogEntry', title=u"hop",
-                                         content=content, content_format=u"text/html")
-        blog_entry_1.set_relations(entry_of=cubicweb_blog)
+            blog_entry_1 = cnx.create_entity('BlogEntry', title=u"hop",
+                                             content=content, content_format=u"text/html")
+            blog_entry_1.cw_set(entry_of=cubicweb_blog)
 
-        xml = blog_entry_1.view('rssitem')
-        self.assertEqual(xml.count("toto"), 0)
-        self.assertEqual(xml.count("tutu"), content.count("tutu"))
+            xml = blog_entry_1.view('rssitem')
+            self.assertEqual(xml.count("toto"), 0)
+            self.assertEqual(xml.count("tutu"), content.count("tutu"))
 
 
     def test_prevnext(self):
-        req = self.request()
-        e1 = req.create_entity('BlogEntry', title=u'a', content=u'a')
-        e2 = req.create_entity('CWGroup', name=u'NotTheNextOfe1')
-        e3 = req.create_entity('BlogEntry', title=u'b', content=u'b')
-        self.commit()
-        a1 = e1.cw_adapt_to('IPrevNext')
-        self.assertNone(a1.previous_entity())
-        self.assertEqual(u'b', a1.next_entity().title)
-        a3 = e3.cw_adapt_to('IPrevNext')
-        self.assertEqual(u'a', a3.previous_entity().title)
-        self.assertNone(a3.next_entity())
+        with self.admin_access.client_cnx() as cnx:
+            e1 = cnx.create_entity('BlogEntry', title=u'a', content=u'a')
+            e2 = cnx.create_entity('CWGroup', name=u'NotTheNextOfe1')
+            e3 = cnx.create_entity('BlogEntry', title=u'b', content=u'b')
+            cnx.commit()
+            a1 = e1.cw_adapt_to('IPrevNext')
+            self.assertIsNone(a1.previous_entity())
+            self.assertEqual(u'b', a1.next_entity().title)
+            a3 = e3.cw_adapt_to('IPrevNext')
+            self.assertEqual(u'a', a3.previous_entity().title)
+            self.assertIsNone(a3.next_entity())
 
 if __name__ == '__main__':
     unittest_main()