[datafeed] correctly distinguish checked/updated
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 07 Jun 2012 18:24:37 +0200
changeset 8435 5064b6e0d6f4
parent 8434 39c5bb4dcc59
child 8436 150191e45ee5
[datafeed] correctly distinguish checked/updated
server/sources/datafeed.py
sobjects/test/unittest_cwxmlparser.py
--- a/server/sources/datafeed.py	Wed Jun 06 10:30:54 2012 +0200
+++ b/server/sources/datafeed.py	Thu Jun 07 18:24:37 2012 +0200
@@ -278,8 +278,7 @@
         self.source = source
         self.sourceuris = sourceuris
         self.import_log = import_log
-        self.stats = {'created': set(),
-                      'updated': set()}
+        self.stats = {'created': set(), 'updated': set(), 'checked': set()}
 
     def normalize_url(self, url):
         from cubicweb.sobjects import URL_MAPPING # available after registration
@@ -359,6 +358,9 @@
     def notify_updated(self, entity):
         return self.stats['updated'].add(entity.eid)
 
+    def notify_checked(self, entity):
+        return self.stats['checked'].add(entity.eid)
+
     def is_deleted(self, extid, etype, eid):
         """return True if the entity of given external id, entity type and eid
         is actually deleted. Always return True by default, put more sensible
@@ -381,6 +383,7 @@
         entity.complete(tuple(attrs))
         # check modification date and compare attribute values to only update
         # what's actually needed
+        self.notify_checked(entity)
         mdate = attrs.get('modification_date')
         if not mdate or mdate > entity.modification_date:
             attrs = dict( (k, v) for k, v in attrs.iteritems()
--- a/sobjects/test/unittest_cwxmlparser.py	Wed Jun 06 10:30:54 2012 +0200
+++ b/sobjects/test/unittest_cwxmlparser.py	Thu Jun 07 18:24:37 2012 +0200
@@ -197,7 +197,7 @@
                           })
         session = self.repo.internal_session(safe=True)
         stats = dfsource.pull_data(session, force=True, raise_on_error=True)
-        self.assertEqual(sorted(stats.keys()), ['created', 'updated'])
+        self.assertEqual(sorted(stats.keys()), ['checked', 'created', 'updated'])
         self.assertEqual(len(stats['created']), 2)
         self.assertEqual(stats['updated'], set())
 
@@ -233,14 +233,16 @@
         with session.security_enabled(read=False): # avoid Unauthorized due to password selection
             stats = dfsource.pull_data(session, force=True, raise_on_error=True)
         self.assertEqual(stats['created'], set())
-        self.assertEqual(len(stats['updated']), 2)
+        self.assertEqual(len(stats['updated']), 0)
+        self.assertEqual(len(stats['checked']), 2)
         self.repo._type_source_cache.clear()
         self.repo._extid_cache.clear()
         session.set_cnxset()
         with session.security_enabled(read=False): # avoid Unauthorized due to password selection
             stats = dfsource.pull_data(session, force=True, raise_on_error=True)
         self.assertEqual(stats['created'], set())
-        self.assertEqual(len(stats['updated']), 2)
+        self.assertEqual(len(stats['updated']), 0)
+        self.assertEqual(len(stats['checked']), 2)
         session.commit()
 
         # test move to system source