author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 06 Oct 2015 11:19:37 +0200 | |
changeset 10781 | e2ab20561932 |
parent 10603 | 65ad6980976e |
child 11034 | 75d752e6daf7 |
permissions | -rw-r--r-- |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
1 |
# copyright 2011-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
# |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
# This file is part of CubicWeb. |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
# |
822f2530570d
[datafeed] add parser to import cubicweb xml
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 |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
# any later version. |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
# |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
# details. |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
15 |
# |
822f2530570d
[datafeed] add parser to import cubicweb xml
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 |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
from datetime import datetime |
10603
65ad6980976e
[py3k] import URL mangling functions using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10591
diff
changeset
|
20 |
|
65ad6980976e
[py3k] import URL mangling functions using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10591
diff
changeset
|
21 |
from six.moves.urllib.parse import urlsplit, parse_qsl |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
from cubicweb.devtools.testlib import CubicWebTC |
8221
fd02d0120ddc
[test] fix test broken by renaming of module containing the cwxml parser and handling of vid in urls
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8188
diff
changeset
|
24 |
from cubicweb.sobjects.cwxmlparser import CWEntityXMLParser |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
orig_parse = CWEntityXMLParser.parse |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
27 |
|
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
28 |
def parse(self, url): |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
try: |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
url = RELATEDXML[url.split('?')[0]] |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
except KeyError: |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
pass |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
33 |
return orig_parse(self, url) |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
def setUpModule(): |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
36 |
CWEntityXMLParser.parse = parse |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
def tearDownModule(): |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
CWEntityXMLParser.parse = orig_parse |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
|
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
BASEXML = ''.join(u''' |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
<rset size="1"> |
7699
d07cde311630
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7698
diff
changeset
|
44 |
<CWUser eid="5" cwuri="http://pouet.org/5" cwsource="system"> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
<login>sthenault</login> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
46 |
<upassword>toto</upassword> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
<last_login_time>2011-01-25 14:14:06</last_login_time> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
<creation_date>2010-01-22 10:27:59</creation_date> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
<modification_date>2011-01-25 14:14:06</modification_date> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
<use_email role="subject"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
51 |
<EmailAddress cwuri="http://pouet.org/6" eid="6"/> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
</use_email> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
53 |
<in_group role="subject"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
54 |
<CWGroup cwuri="http://pouet.org/7" eid="7"/> |
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
55 |
<CWGroup cwuri="http://pouet.org/8" eid="8"/> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
56 |
</in_group> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
57 |
<tags role="object"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
58 |
<Tag cwuri="http://pouet.org/9" eid="9"/> |
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
59 |
<Tag cwuri="http://pouet.org/10" eid="10"/> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
60 |
</tags> |
7553
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
61 |
<in_state role="subject"> |
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
62 |
<State cwuri="http://pouet.org/11" eid="11" name="activated"/> |
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
63 |
</in_state> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
64 |
</CWUser> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
65 |
</rset> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
66 |
'''.splitlines()) |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
67 |
|
7553
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
68 |
RELATEDXML = { |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
69 |
'http://pouet.org/6': u''' |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
70 |
<rset size="1"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
71 |
<EmailAddress eid="6" cwuri="http://pouet.org/6"> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
72 |
<address>syt@logilab.fr</address> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
73 |
<modification_date>2010-04-13 14:35:56</modification_date> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
74 |
<creation_date>2010-04-13 14:35:56</creation_date> |
7916
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
75 |
<tags role="object"> |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
76 |
<Tag cwuri="http://pouet.org/9" eid="9"/> |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
77 |
</tags> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
78 |
</EmailAddress> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
79 |
</rset> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
80 |
''', |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
81 |
'http://pouet.org/7': u''' |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
82 |
<rset size="1"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
83 |
<CWGroup eid="7" cwuri="http://pouet.org/7"> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
84 |
<name>users</name> |
7916
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
85 |
<tags role="object"> |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
86 |
<Tag cwuri="http://pouet.org/9" eid="9"/> |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
87 |
</tags> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
88 |
</CWGroup> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
89 |
</rset> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
90 |
''', |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
91 |
'http://pouet.org/8': u''' |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
92 |
<rset size="1"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
93 |
<CWGroup eid="8" cwuri="http://pouet.org/8"> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
94 |
<name>unknown</name> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
95 |
</CWGroup> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
96 |
</rset> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
97 |
''', |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
98 |
'http://pouet.org/9': u''' |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
99 |
<rset size="1"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
100 |
<Tag eid="9" cwuri="http://pouet.org/9"> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
101 |
<name>hop</name> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
102 |
</Tag> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
103 |
</rset> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
104 |
''', |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
105 |
'http://pouet.org/10': u''' |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
106 |
<rset size="1"> |
6968
2abc3befb788
[test] update cwxml tests: computed cwuri have changed, and parser.parse isn't anymore a static method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6960
diff
changeset
|
107 |
<Tag eid="10" cwuri="http://pouet.org/10"> |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
108 |
<name>unknown</name> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
109 |
</Tag> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
110 |
</rset> |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
111 |
''', |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
112 |
} |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
113 |
|
7534
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
114 |
|
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
115 |
OTHERXML = ''.join(u''' |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
116 |
<rset size="1"> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
117 |
<CWUser eid="5" cwuri="http://pouet.org/5" cwsource="myfeed"> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
118 |
<login>sthenault</login> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
119 |
<upassword>toto</upassword> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
120 |
<last_login_time>2011-01-25 14:14:06</last_login_time> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
121 |
<creation_date>2010-01-22 10:27:59</creation_date> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
122 |
<modification_date>2011-01-25 14:14:06</modification_date> |
7708
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
123 |
<in_group role="subject"> |
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
124 |
<CWGroup cwuri="http://pouet.org/7" eid="7"/> |
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
125 |
</in_group> |
7534
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
126 |
</CWUser> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
127 |
</rset> |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
128 |
'''.splitlines() |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
129 |
) |
7699
d07cde311630
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7698
diff
changeset
|
130 |
|
d07cde311630
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7698
diff
changeset
|
131 |
|
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
132 |
class CWEntityXMLParserTC(CubicWebTC): |
7699
d07cde311630
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7698
diff
changeset
|
133 |
"""/!\ this test use a pre-setup database /!\, if you modify above xml, |
d07cde311630
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7698
diff
changeset
|
134 |
REMOVE THE DATABASE TEMPLATE else it won't be considered |
d07cde311630
[datafeed] properly take care to cwsource=system in imported xml. Closes #1877017
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7698
diff
changeset
|
135 |
""" |
7534
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
136 |
test_db_id = 'xmlparser' |
9879
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
137 |
|
10240
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
138 |
def assertURLEquiv(self, first, second): |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
139 |
# ignore ordering differences in query params |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
140 |
parsed_first = urlsplit(first) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
141 |
parsed_second = urlsplit(second) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
142 |
self.assertEqual(parsed_first.scheme, parsed_second.scheme) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
143 |
self.assertEqual(parsed_first.netloc, parsed_second.netloc) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
144 |
self.assertEqual(parsed_first.path, parsed_second.path) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
145 |
self.assertEqual(parsed_first.fragment, parsed_second.fragment) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
146 |
self.assertCountEqual(parse_qsl(parsed_first.query), parse_qsl(parsed_second.query)) |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
147 |
|
7534
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
148 |
@classmethod |
9879
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
149 |
def pre_setup_database(cls, cnx, config): |
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
150 |
myfeed = cnx.create_entity('CWSource', name=u'myfeed', type=u'datafeed', |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
151 |
parser=u'cw.entityxml', url=BASEXML) |
9879
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
152 |
myotherfeed = cnx.create_entity('CWSource', name=u'myotherfeed', type=u'datafeed', |
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
153 |
parser=u'cw.entityxml', url=OTHERXML) |
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
154 |
cnx.commit() |
7708
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
155 |
myfeed.init_mapping([(('CWUser', 'use_email', '*'), |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
156 |
u'role=subject\naction=copy'), |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
157 |
(('CWUser', 'in_group', '*'), |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
158 |
u'role=subject\naction=link\nlinkattr=name'), |
7553
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
159 |
(('CWUser', 'in_state', '*'), |
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
160 |
u'role=subject\naction=link\nlinkattr=name'), |
7916
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
161 |
(('*', 'tags', '*'), |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
162 |
u'role=object\naction=link-or-create\nlinkattr=name'), |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
163 |
]) |
7708
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
164 |
myotherfeed.init_mapping([(('CWUser', 'in_group', '*'), |
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
165 |
u'role=subject\naction=link\nlinkattr=name'), |
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
166 |
(('CWUser', 'in_state', '*'), |
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
167 |
u'role=subject\naction=link\nlinkattr=name'), |
45be3a9debe6
[datafeed] for datafeed source, we don't want commit in extid2eid but explicitly handled by the source. Also, we should use 'safe' internal session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7701
diff
changeset
|
168 |
]) |
9879
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
169 |
cnx.create_entity('Tag', name=u'hop') |
21278eb03bbf
[datafeed sources] finish the session -> cnx switch
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9748
diff
changeset
|
170 |
cnx.commit() |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
171 |
|
7531
e891ca479586
[datafeed, cwxml] parser now try to complete source's urls so one can add url such as <myinstance>/project. Closes #1759908
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7463
diff
changeset
|
172 |
def test_complete_url(self): |
e891ca479586
[datafeed, cwxml] parser now try to complete source's urls so one can add url such as <myinstance>/project. Closes #1759908
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7463
diff
changeset
|
173 |
dfsource = self.repo.sources_by_uri['myfeed'] |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
174 |
with self.admin_access.repo_cnx() as cnx: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
175 |
parser = dfsource._get_parser(cnx) |
10240
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
176 |
self.assertURLEquiv(parser.complete_url('http://www.cubicweb.org/CWUser'), |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
177 |
'http://www.cubicweb.org/CWUser?relation=tags-object&relation=in_group-subject&relation=in_state-subject&relation=use_email-subject') |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
178 |
self.assertURLEquiv(parser.complete_url('http://www.cubicweb.org/cwuser'), |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
179 |
'http://www.cubicweb.org/cwuser?relation=tags-object&relation=in_group-subject&relation=in_state-subject&relation=use_email-subject') |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
180 |
self.assertURLEquiv(parser.complete_url('http://www.cubicweb.org/cwuser?vid=rdf&relation=hop'), |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
181 |
'http://www.cubicweb.org/cwuser?relation=hop&relation=tags-object&relation=in_group-subject&relation=in_state-subject&relation=use_email-subject&vid=rdf') |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
182 |
self.assertURLEquiv(parser.complete_url('http://www.cubicweb.org/?rql=cwuser&vid=rdf&relation=hop'), |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
183 |
'http://www.cubicweb.org/?rql=cwuser&relation=hop&vid=rdf') |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
184 |
self.assertURLEquiv(parser.complete_url('http://www.cubicweb.org/?rql=cwuser&relation=hop'), |
6ec03928257f
[sobjects/test] Fix dependency on predictable hashing
Julien Cristau <julien.cristau@logilab.fr>
parents:
9879
diff
changeset
|
185 |
'http://www.cubicweb.org/?rql=cwuser&relation=hop') |
7531
e891ca479586
[datafeed, cwxml] parser now try to complete source's urls so one can add url such as <myinstance>/project. Closes #1759908
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7463
diff
changeset
|
186 |
|
e891ca479586
[datafeed, cwxml] parser now try to complete source's urls so one can add url such as <myinstance>/project. Closes #1759908
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7463
diff
changeset
|
187 |
|
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
188 |
def test_actions(self): |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
189 |
dfsource = self.repo.sources_by_uri['myfeed'] |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
190 |
self.assertEqual(dfsource.mapping, |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
191 |
{u'CWUser': { |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
192 |
(u'in_group', u'subject', u'link'): [ |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
193 |
(u'CWGroup', {u'linkattr': u'name'})], |
7553
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
194 |
(u'in_state', u'subject', u'link'): [ |
935423529f45
[datafeed cw parser] refactor: split logic that was in the parser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7552
diff
changeset
|
195 |
(u'State', {u'linkattr': u'name'})], |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
196 |
(u'tags', u'object', u'link-or-create'): [ |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
197 |
(u'Tag', {u'linkattr': u'name'})], |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
198 |
(u'use_email', u'subject', u'copy'): [ |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
199 |
(u'EmailAddress', {})] |
7916
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
200 |
}, |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
201 |
u'CWGroup': { |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
202 |
(u'tags', u'object', u'link-or-create'): [ |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
203 |
(u'Tag', {u'linkattr': u'name'})], |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
204 |
}, |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
205 |
u'EmailAddress': { |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
206 |
(u'tags', u'object', u'link-or-create'): [ |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
207 |
(u'Tag', {u'linkattr': u'name'})], |
54e240c1b419
[datafeed parser] properly recurse on nodes to follow all mapped relations (closes #1988432)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7708
diff
changeset
|
208 |
}, |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
209 |
}) |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
210 |
with self.repo.internal_cnx() as cnx: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
211 |
stats = dfsource.pull_data(cnx, force=True, raise_on_error=True) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
212 |
self.assertEqual(sorted(stats), ['checked', 'created', 'updated']) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
213 |
self.assertEqual(len(stats['created']), 2) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
214 |
self.assertEqual(stats['updated'], set()) |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
215 |
|
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
216 |
with self.admin_access.web_request() as req: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
217 |
user = req.execute('CWUser X WHERE X login "sthenault"').get_entity(0, 0) |
10591
8e46ed1a0b8a
[py3k] octals and long
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
10549
diff
changeset
|
218 |
self.assertEqual(user.creation_date, datetime(2010, 1, 22, 10, 27, 59)) |
8e46ed1a0b8a
[py3k] octals and long
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
10549
diff
changeset
|
219 |
self.assertEqual(user.modification_date, datetime(2011, 1, 25, 14, 14, 6)) |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
220 |
self.assertEqual(user.cwuri, 'http://pouet.org/5') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
221 |
self.assertEqual(user.cw_source[0].name, 'myfeed') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
222 |
self.assertEqual(user.absolute_url(), 'http://pouet.org/5') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
223 |
self.assertEqual(len(user.use_email), 1) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
224 |
# copy action |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
225 |
email = user.use_email[0] |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
226 |
self.assertEqual(email.address, 'syt@logilab.fr') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
227 |
self.assertEqual(email.cwuri, 'http://pouet.org/6') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
228 |
self.assertEqual(email.absolute_url(), 'http://pouet.org/6') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
229 |
self.assertEqual(email.cw_source[0].name, 'myfeed') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
230 |
self.assertEqual(len(email.reverse_tags), 1) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
231 |
self.assertEqual(email.reverse_tags[0].name, 'hop') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
232 |
# link action |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
233 |
self.assertFalse(req.execute('CWGroup X WHERE X name "unknown"')) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
234 |
groups = sorted([g.name for g in user.in_group]) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
235 |
self.assertEqual(groups, ['users']) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
236 |
group = user.in_group[0] |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
237 |
self.assertEqual(len(group.reverse_tags), 1) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
238 |
self.assertEqual(group.reverse_tags[0].name, 'hop') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
239 |
# link or create action |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
240 |
tags = set([(t.name, t.cwuri.replace(str(t.eid), ''), t.cw_source[0].name) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
241 |
for t in user.reverse_tags]) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
242 |
self.assertEqual(tags, set((('hop', 'http://testing.fr/cubicweb/', 'system'), |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
243 |
('unknown', 'http://testing.fr/cubicweb/', 'system'))) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
244 |
) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
245 |
with self.repo.internal_cnx() as cnx: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
246 |
stats = dfsource.pull_data(cnx, force=True, raise_on_error=True) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
247 |
self.assertEqual(stats['created'], set()) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
248 |
self.assertEqual(len(stats['updated']), 0) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
249 |
self.assertEqual(len(stats['checked']), 2) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
250 |
self.repo._type_source_cache.clear() |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
251 |
self.repo._extid_cache.clear() |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
252 |
stats = dfsource.pull_data(cnx, force=True, raise_on_error=True) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
253 |
self.assertEqual(stats['created'], set()) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
254 |
self.assertEqual(len(stats['updated']), 0) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
255 |
self.assertEqual(len(stats['checked']), 2) |
7399
972ed1843bd8
[multi-sources] support for moving an entity from an external source (closes #343818)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7351
diff
changeset
|
256 |
|
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
257 |
# test move to system source |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
258 |
cnx.execute('SET X cw_source S WHERE X eid %(x)s, S name "system"', {'x': email.eid}) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
259 |
cnx.commit() |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
260 |
rset = cnx.execute('EmailAddress X WHERE X address "syt@logilab.fr"') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
261 |
self.assertEqual(len(rset), 1) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
262 |
e = rset.get_entity(0, 0) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
263 |
self.assertEqual(e.eid, email.eid) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
264 |
self.assertEqual(e.cw_metainformation(), {'source': {'type': u'native', 'uri': u'system', |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
265 |
'use-cwuri-as-url': False}, |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
266 |
'type': 'EmailAddress', |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
267 |
'extid': None}) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
268 |
self.assertEqual(e.cw_source[0].name, 'system') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
269 |
self.assertEqual(e.reverse_use_email[0].login, 'sthenault') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
270 |
# test everything is still fine after source synchronization |
10549
5fc21bf2684f
[hooks] base64-encode extid before inserting it into moved_entities
Julien Cristau <julien.cristau@logilab.fr>
parents:
10240
diff
changeset
|
271 |
# clear caches to make sure we look at the moved_entities table |
5fc21bf2684f
[hooks] base64-encode extid before inserting it into moved_entities
Julien Cristau <julien.cristau@logilab.fr>
parents:
10240
diff
changeset
|
272 |
self.repo._type_source_cache.clear() |
5fc21bf2684f
[hooks] base64-encode extid before inserting it into moved_entities
Julien Cristau <julien.cristau@logilab.fr>
parents:
10240
diff
changeset
|
273 |
self.repo._extid_cache.clear() |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
274 |
stats = dfsource.pull_data(cnx, force=True, raise_on_error=True) |
10549
5fc21bf2684f
[hooks] base64-encode extid before inserting it into moved_entities
Julien Cristau <julien.cristau@logilab.fr>
parents:
10240
diff
changeset
|
275 |
self.assertEqual(stats['updated'], set((email.eid,))) |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
276 |
rset = cnx.execute('EmailAddress X WHERE X address "syt@logilab.fr"') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
277 |
self.assertEqual(len(rset), 1) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
278 |
e = rset.get_entity(0, 0) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
279 |
self.assertEqual(e.eid, email.eid) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
280 |
self.assertEqual(e.cw_metainformation(), {'source': {'type': u'native', 'uri': u'system', |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
281 |
'use-cwuri-as-url': False}, |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
282 |
'type': 'EmailAddress', |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
283 |
'extid': None}) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
284 |
self.assertEqual(e.cw_source[0].name, 'system') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
285 |
self.assertEqual(e.reverse_use_email[0].login, 'sthenault') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
286 |
cnx.commit() |
7399
972ed1843bd8
[multi-sources] support for moving an entity from an external source (closes #343818)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7351
diff
changeset
|
287 |
|
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
288 |
# test delete entity |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
289 |
e.cw_delete() |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
290 |
cnx.commit() |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
291 |
# test everything is still fine after source synchronization |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
292 |
stats = dfsource.pull_data(cnx, force=True, raise_on_error=True) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
293 |
rset = cnx.execute('EmailAddress X WHERE X address "syt@logilab.fr"') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
294 |
self.assertEqual(len(rset), 0) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
295 |
rset = cnx.execute('Any X WHERE X use_email E, X login "sthenault"') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
296 |
self.assertEqual(len(rset), 0) |
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
297 |
|
7534
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
298 |
def test_external_entity(self): |
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
299 |
dfsource = self.repo.sources_by_uri['myotherfeed'] |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
300 |
with self.repo.internal_cnx() as cnx: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
301 |
stats = dfsource.pull_data(cnx, force=True, raise_on_error=True) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
302 |
user = cnx.execute('CWUser X WHERE X login "sthenault"').get_entity(0, 0) |
10591
8e46ed1a0b8a
[py3k] octals and long
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
10549
diff
changeset
|
303 |
self.assertEqual(user.creation_date, datetime(2010, 1, 22, 10, 27, 59)) |
8e46ed1a0b8a
[py3k] octals and long
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
10549
diff
changeset
|
304 |
self.assertEqual(user.modification_date, datetime(2011, 1, 25, 14, 14, 6)) |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
305 |
self.assertEqual(user.cwuri, 'http://pouet.org/5') |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
306 |
self.assertEqual(user.cw_source[0].name, 'myfeed') |
7534
d58a9d96aad8
[datafeed, cw.xml] xml now carry entity's source information, interpreted at the other end so that for instance when an entity from elo is seen when importing cwo, it's properly marked as coming from elo source if one exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7531
diff
changeset
|
307 |
|
7700
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
308 |
def test_noerror_missing_fti_attribute(self): |
7698
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
309 |
dfsource = self.repo.sources_by_uri['myfeed'] |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
310 |
with self.repo.internal_cnx() as cnx: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
311 |
parser = dfsource._get_parser(cnx) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
312 |
dfsource.process_urls(parser, [''' |
7698
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
313 |
<rset size="1"> |
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
314 |
<Card eid="50" cwuri="http://pouet.org/50" cwsource="system"> |
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
315 |
<title>how-to</title> |
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
316 |
</Card> |
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
317 |
</rset> |
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
318 |
'''], raise_on_error=True) |
1c7411535c2d
[datafeed / fti] rather control a 'complete' parameter than setting empty attribute values
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7689
diff
changeset
|
319 |
|
7700
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
320 |
def test_noerror_unspecified_date(self): |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
321 |
dfsource = self.repo.sources_by_uri['myfeed'] |
9748
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
322 |
with self.repo.internal_cnx() as cnx: |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
323 |
parser = dfsource._get_parser(cnx) |
5ee3d16b0df0
[test] update sobjects/test/unittest_cwxmlparser to cw 3.19 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8696
diff
changeset
|
324 |
dfsource.process_urls(parser, [''' |
7700
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
325 |
<rset size="1"> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
326 |
<Card eid="50" cwuri="http://pouet.org/50" cwsource="system"> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
327 |
<title>how-to</title> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
328 |
<content>how-to</content> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
329 |
<synopsis>how-to</synopsis> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
330 |
<creation_date/> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
331 |
</Card> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
332 |
</rset> |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
333 |
'''], raise_on_error=True) |
0010dde5352a
[datafeed] closes #1875322: empty tag means None value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7699
diff
changeset
|
334 |
|
6960
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
335 |
if __name__ == '__main__': |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
336 |
from logilab.common.testlib import unittest_main |
822f2530570d
[datafeed] add parser to import cubicweb xml
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
337 |
unittest_main() |