author | Julien Cristau <julien.cristau@logilab.fr> |
Thu, 25 Sep 2014 14:24:20 +0200 | |
changeset 9985 | c4e740e50fc7 |
parent 9860 | e24bf60428d3 |
child 9897 | fa44db7da2dc |
permissions | -rw-r--r-- |
9798
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
1 |
# copyright 2011-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
# |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
# This file is part of CubicWeb. |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
# |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
# any later version. |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
# |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
# details. |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
15 |
# |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
|
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
from datetime import timedelta |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
20 |
|
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
from cubicweb.devtools.testlib import CubicWebTC |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
from cubicweb.server.sources import datafeed |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
|
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
|
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
class DataFeedTC(CubicWebTC): |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
def setup_database(self): |
9798
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
27 |
with self.admin_access.repo_cnx() as cnx: |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
28 |
cnx.create_entity('CWSource', name=u'myfeed', type=u'datafeed', |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
29 |
parser=u'testparser', url=u'ignored', |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
30 |
config=u'synchronization-interval=1min') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
31 |
cnx.commit() |
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
|
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
def test(self): |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
self.assertIn('myfeed', self.repo.sources_by_uri) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
dfsource = self.repo.sources_by_uri['myfeed'] |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
self.assertEqual(dfsource.latest_retrieval, None) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
self.assertEqual(dfsource.synchro_interval, timedelta(seconds=60)) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
self.assertFalse(dfsource.fresh()) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
|
7978
b6150210f692
[test] fix datafeed test, we have to use an internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7735
diff
changeset
|
40 |
|
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
class AParser(datafeed.DataFeedParser): |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
__regid__ = 'testparser' |
7386
206890413858
[repo test] datafeed parser's process method should now take raise_on_error argument
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6957
diff
changeset
|
43 |
def process(self, url, raise_on_error=False): |
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
entity = self.extid2entity('http://www.cubicweb.org/', 'Card', |
7978
b6150210f692
[test] fix datafeed test, we have to use an internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7735
diff
changeset
|
45 |
item={'title': u'cubicweb.org', |
b6150210f692
[test] fix datafeed test, we have to use an internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7735
diff
changeset
|
46 |
'content': u'the cw web site'}) |
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
if not self.created_during_pull(entity): |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
self.notify_updated(entity) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
def before_entity_copy(self, entity, sourceparams): |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
entity.cw_edited.update(sourceparams['item']) |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
|
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
with self.temporary_appobjects(AParser): |
9798
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
53 |
with self.repo.internal_cnx() as cnx: |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
54 |
stats = dfsource.pull_data(cnx, force=True) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
55 |
cnx.commit() |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
56 |
# test import stats |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
57 |
self.assertEqual(sorted(stats), ['checked', 'created', 'updated']) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
58 |
self.assertEqual(len(stats['created']), 1) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
59 |
entity = cnx.execute('Card X').get_entity(0, 0) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
60 |
self.assertIn(entity.eid, stats['created']) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
61 |
self.assertEqual(stats['updated'], set()) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
62 |
# test imported entities |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
63 |
self.assertEqual(entity.title, 'cubicweb.org') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
64 |
self.assertEqual(entity.content, 'the cw web site') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
65 |
self.assertEqual(entity.cwuri, 'http://www.cubicweb.org/') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
66 |
self.assertEqual(entity.cw_source[0].name, 'myfeed') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
67 |
self.assertEqual(entity.cw_metainformation(), |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
68 |
{'type': 'Card', |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
69 |
'source': {'uri': 'myfeed', 'type': 'datafeed', 'use-cwuri-as-url': True}, |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
70 |
'extid': 'http://www.cubicweb.org/'} |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
71 |
) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
72 |
self.assertEqual(entity.absolute_url(), 'http://www.cubicweb.org/') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
73 |
# test repo cache keys |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
74 |
self.assertEqual(self.repo._type_source_cache[entity.eid], |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
75 |
('Card', 'http://www.cubicweb.org/', 'myfeed')) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
76 |
self.assertEqual(self.repo._extid_cache['http://www.cubicweb.org/'], |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
77 |
entity.eid) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
78 |
# test repull |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
79 |
stats = dfsource.pull_data(cnx, force=True) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
80 |
self.assertEqual(stats['created'], set()) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
81 |
self.assertEqual(stats['updated'], set((entity.eid,))) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
82 |
# test repull with caches reseted |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
83 |
self.repo._type_source_cache.clear() |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
84 |
self.repo._extid_cache.clear() |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
85 |
stats = dfsource.pull_data(cnx, force=True) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
86 |
self.assertEqual(stats['created'], set()) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
87 |
self.assertEqual(stats['updated'], set((entity.eid,))) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
88 |
self.assertEqual(self.repo._type_source_cache[entity.eid], |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
89 |
('Card', 'http://www.cubicweb.org/', 'myfeed')) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
90 |
self.assertEqual(self.repo._extid_cache['http://www.cubicweb.org/'], |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
91 |
entity.eid) |
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
92 |
|
9860
e24bf60428d3
[tests/datafeed] use the new connection api (a small leftover)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9798
diff
changeset
|
93 |
self.assertEqual(dfsource.source_cwuris(cnx), |
e24bf60428d3
[tests/datafeed] use the new connection api (a small leftover)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9798
diff
changeset
|
94 |
{'http://www.cubicweb.org/': (entity.eid, 'Card')} |
e24bf60428d3
[tests/datafeed] use the new connection api (a small leftover)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9798
diff
changeset
|
95 |
) |
e24bf60428d3
[tests/datafeed] use the new connection api (a small leftover)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9798
diff
changeset
|
96 |
self.assertTrue(dfsource.latest_retrieval) |
e24bf60428d3
[tests/datafeed] use the new connection api (a small leftover)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9798
diff
changeset
|
97 |
self.assertTrue(dfsource.fresh()) |
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
98 |
|
7735
71adfd6bab38
[source] update system table and internal structures on source renaming. Closes #1896721
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7717
diff
changeset
|
99 |
# test_rename_source |
9798
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
100 |
with self.admin_access.repo_cnx() as cnx: |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
101 |
cnx.execute('SET S name "myrenamedfeed" WHERE S is CWSource, S name "myfeed"') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
102 |
cnx.commit() |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
103 |
entity = cnx.execute('Card X').get_entity(0, 0) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
104 |
self.assertEqual(entity.cwuri, 'http://www.cubicweb.org/') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
105 |
self.assertEqual(entity.cw_source[0].name, 'myrenamedfeed') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
106 |
self.assertEqual(entity.cw_metainformation(), |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
107 |
{'type': 'Card', |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
108 |
'source': {'uri': 'myrenamedfeed', 'type': 'datafeed', 'use-cwuri-as-url': True}, |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
109 |
'extid': 'http://www.cubicweb.org/'} |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
110 |
) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
111 |
self.assertEqual(self.repo._type_source_cache[entity.eid], |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
112 |
('Card', 'http://www.cubicweb.org/', 'myrenamedfeed')) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
113 |
self.assertEqual(self.repo._extid_cache['http://www.cubicweb.org/'], |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
114 |
entity.eid) |
7735
71adfd6bab38
[source] update system table and internal structures on source renaming. Closes #1896721
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7717
diff
changeset
|
115 |
|
9798
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
116 |
# test_delete_source |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
117 |
cnx.execute('DELETE CWSource S WHERE S name "myrenamedfeed"') |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
118 |
cnx.commit() |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
119 |
self.assertFalse(cnx.execute('Card X WHERE X title "cubicweb.org"')) |
1c105cf42904
[tests/datafeed] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9469
diff
changeset
|
120 |
self.assertFalse(cnx.execute('Any X WHERE X has_text "cubicweb.org"')) |
7650
278fe9c1f3ad
[repo] closes #1821172: fix source deletion
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7631
diff
changeset
|
121 |
|
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
122 |
if __name__ == '__main__': |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
123 |
from logilab.common.testlib import unittest_main |
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
124 |
unittest_main() |