[test] fix datafeed test, we have to use an internal session stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 21 Oct 2011 09:23:43 +0200
branchstable
changeset 7978 b6150210f692
parent 7977 e2d3ff3e7660
child 7979 8bd5031e2201
child 7982 77ed9b2fc9a5
[test] fix datafeed test, we have to use an internal session
server/test/unittest_datafeed.py
--- a/server/test/unittest_datafeed.py	Fri Oct 21 09:23:43 2011 +0200
+++ b/server/test/unittest_datafeed.py	Fri Oct 21 09:23:43 2011 +0200
@@ -37,19 +37,21 @@
         self.assertEqual(dfsource.synchro_interval, timedelta(seconds=60))
         self.assertFalse(dfsource.fresh())
 
+
         class AParser(datafeed.DataFeedParser):
             __regid__ = 'testparser'
             def process(self, url, raise_on_error=False):
                 entity = self.extid2entity('http://www.cubicweb.org/', 'Card',
-                                  item={'title': u'cubicweb.org',
-                                        'content': u'the cw web site'})
+                                           item={'title': u'cubicweb.org',
+                                                 'content': u'the cw web site'})
                 if not self.created_during_pull(entity):
                     self.notify_updated(entity)
             def before_entity_copy(self, entity, sourceparams):
                 entity.cw_edited.update(sourceparams['item'])
 
         with self.temporary_appobjects(AParser):
-            stats = dfsource.pull_data(self.session, force=True)
+            session = self.repo.internal_session()
+            stats = dfsource.pull_data(session, force=True)
             self.commit()
             # test import stats
             self.assertEqual(sorted(stats.keys()), ['created', 'updated'])
@@ -74,13 +76,15 @@
             self.assertEqual(self.repo._extid_cache[('http://www.cubicweb.org/', 'system')],
                              entity.eid)
             # test repull
-            stats = dfsource.pull_data(self.session, force=True)
+            session.set_cnxset()
+            stats = dfsource.pull_data(session, force=True)
             self.assertEqual(stats['created'], set())
             self.assertEqual(stats['updated'], set((entity.eid,)))
             # test repull with caches reseted
             self.repo._type_source_cache.clear()
             self.repo._extid_cache.clear()
-            stats = dfsource.pull_data(self.session, force=True)
+            session.set_cnxset()
+            stats = dfsource.pull_data(session, force=True)
             self.assertEqual(stats['created'], set())
             self.assertEqual(stats['updated'], set((entity.eid,)))
             self.assertEqual(self.repo._type_source_cache[entity.eid],