update repo sources on update of source's entities .url attribute
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 08 Sep 2015 09:05:31 +0200
changeset 10956 208c9ac8edbb
parent 10951 ef1cfc80d51c
child 10960 9e64fddebc89
update repo sources on update of source's entities .url attribute
hooks/syncsources.py
server/test/unittest_datafeed.py
--- a/hooks/syncsources.py	Wed Dec 09 16:15:00 2015 +0100
+++ b/hooks/syncsources.py	Tue Sep 08 09:05:31 2015 +0200
@@ -119,7 +119,7 @@
                 msg = _("You cannot rename the system source")
                 raise validation_error(self.entity, {('name', 'subject'): msg})
             SourceRenamedOp(self._cw, oldname=oldname, newname=newname)
-        if 'config' in self.entity.cw_edited:
+        if 'config' in self.entity.cw_edited or 'url' in self.entity.cw_edited:
             if self.entity.name == 'system' and self.entity.config:
                 msg = _("Configuration of the system source goes to "
                         "the 'sources' file, not in the database")
--- a/server/test/unittest_datafeed.py	Wed Dec 09 16:15:00 2015 +0100
+++ b/server/test/unittest_datafeed.py	Tue Sep 08 09:05:31 2015 +0200
@@ -142,6 +142,14 @@
                 self.assertEqual(200, value.getcode())
                 self.assertEqual('a string', value.geturl())
 
+    def test_update_url(self):
+        dfsource = self.repo.sources_by_uri[u'รด myfeed']
+        with self.admin_access.repo_cnx() as cnx:
+            cnx.entity_from_eid(dfsource.eid).cw_set(url=u"http://pouet.com\nhttp://pouet.org")
+            self.assertEqual(dfsource.urls, [u'ignored'])
+            cnx.commit()
+        self.assertEqual(dfsource.urls, [u"http://pouet.com", u"http://pouet.org"])
+
 
 class DataFeedConfigTC(CubicWebTC):