80 self.assertEqual(entity.cwuri, 'http://www.cubicweb.org/') |
80 self.assertEqual(entity.cwuri, 'http://www.cubicweb.org/') |
81 self.assertEqual(entity.cw_source[0].name, 'myfeed') |
81 self.assertEqual(entity.cw_source[0].name, 'myfeed') |
82 self.assertEqual(entity.cw_metainformation(), |
82 self.assertEqual(entity.cw_metainformation(), |
83 {'type': 'Card', |
83 {'type': 'Card', |
84 'source': {'uri': 'myfeed', 'type': 'datafeed', 'use-cwuri-as-url': True}, |
84 'source': {'uri': 'myfeed', 'type': 'datafeed', 'use-cwuri-as-url': True}, |
85 'extid': 'http://www.cubicweb.org/'} |
85 'extid': b'http://www.cubicweb.org/'} |
86 ) |
86 ) |
87 self.assertEqual(entity.absolute_url(), 'http://www.cubicweb.org/') |
87 self.assertEqual(entity.absolute_url(), 'http://www.cubicweb.org/') |
88 # test repo cache keys |
88 # test repo cache keys |
89 self.assertEqual(self.repo._type_source_cache[entity.eid], |
89 self.assertEqual(self.repo._type_source_cache[entity.eid], |
90 ('Card', 'http://www.cubicweb.org/', 'myfeed')) |
90 ('Card', b'http://www.cubicweb.org/', 'myfeed')) |
91 self.assertEqual(self.repo._extid_cache['http://www.cubicweb.org/'], |
91 self.assertEqual(self.repo._extid_cache[b'http://www.cubicweb.org/'], |
92 entity.eid) |
92 entity.eid) |
93 # test repull |
93 # test repull |
94 stats = dfsource.pull_data(cnx, force=True) |
94 stats = dfsource.pull_data(cnx, force=True) |
95 self.assertEqual(stats['created'], set()) |
95 self.assertEqual(stats['created'], set()) |
96 self.assertEqual(stats['updated'], set((entity.eid,))) |
96 self.assertEqual(stats['updated'], set((entity.eid,))) |
99 self.repo._extid_cache.clear() |
99 self.repo._extid_cache.clear() |
100 stats = dfsource.pull_data(cnx, force=True) |
100 stats = dfsource.pull_data(cnx, force=True) |
101 self.assertEqual(stats['created'], set()) |
101 self.assertEqual(stats['created'], set()) |
102 self.assertEqual(stats['updated'], set((entity.eid,))) |
102 self.assertEqual(stats['updated'], set((entity.eid,))) |
103 self.assertEqual(self.repo._type_source_cache[entity.eid], |
103 self.assertEqual(self.repo._type_source_cache[entity.eid], |
104 ('Card', 'http://www.cubicweb.org/', 'myfeed')) |
104 ('Card', b'http://www.cubicweb.org/', 'myfeed')) |
105 self.assertEqual(self.repo._extid_cache['http://www.cubicweb.org/'], |
105 self.assertEqual(self.repo._extid_cache[b'http://www.cubicweb.org/'], |
106 entity.eid) |
106 entity.eid) |
107 |
107 |
108 self.assertEqual(dfsource.source_cwuris(cnx), |
108 self.assertEqual(dfsource.source_cwuris(cnx), |
109 {'http://www.cubicweb.org/': (entity.eid, 'Card')} |
109 {b'http://www.cubicweb.org/': (entity.eid, 'Card')} |
110 ) |
110 ) |
111 self.assertTrue(dfsource.latest_retrieval) |
111 self.assertTrue(dfsource.latest_retrieval) |
112 self.assertTrue(dfsource.fresh()) |
112 self.assertTrue(dfsource.fresh()) |
113 |
113 |
114 # test_rename_source |
114 # test_rename_source |
119 self.assertEqual(entity.cwuri, 'http://www.cubicweb.org/') |
119 self.assertEqual(entity.cwuri, 'http://www.cubicweb.org/') |
120 self.assertEqual(entity.cw_source[0].name, 'myrenamedfeed') |
120 self.assertEqual(entity.cw_source[0].name, 'myrenamedfeed') |
121 self.assertEqual(entity.cw_metainformation(), |
121 self.assertEqual(entity.cw_metainformation(), |
122 {'type': 'Card', |
122 {'type': 'Card', |
123 'source': {'uri': 'myrenamedfeed', 'type': 'datafeed', 'use-cwuri-as-url': True}, |
123 'source': {'uri': 'myrenamedfeed', 'type': 'datafeed', 'use-cwuri-as-url': True}, |
124 'extid': 'http://www.cubicweb.org/'} |
124 'extid': b'http://www.cubicweb.org/'} |
125 ) |
125 ) |
126 self.assertEqual(self.repo._type_source_cache[entity.eid], |
126 self.assertEqual(self.repo._type_source_cache[entity.eid], |
127 ('Card', 'http://www.cubicweb.org/', 'myrenamedfeed')) |
127 ('Card', b'http://www.cubicweb.org/', 'myrenamedfeed')) |
128 self.assertEqual(self.repo._extid_cache['http://www.cubicweb.org/'], |
128 self.assertEqual(self.repo._extid_cache[b'http://www.cubicweb.org/'], |
129 entity.eid) |
129 entity.eid) |
130 |
130 |
131 # test_delete_source |
131 # test_delete_source |
132 cnx.execute('DELETE CWSource S WHERE S name "myrenamedfeed"') |
132 cnx.execute('DELETE CWSource S WHERE S name "myrenamedfeed"') |
133 cnx.commit() |
133 cnx.commit() |