|
4 | 4 | import pytest |
5 | 5 |
|
6 | 6 | from aleph.db.models import MessageDb |
| 7 | +from aleph.db.models.messages import MessageStatusDb |
7 | 8 | from aleph.db.models.posts import PostDb |
8 | 9 | from aleph.types.db_session import DbSessionFactory |
9 | 10 |
|
@@ -58,14 +59,13 @@ async def test_get_posts_refs( |
58 | 59 | ccn_api_client, |
59 | 60 | session_factory: DbSessionFactory, |
60 | 61 | fixture_posts: Sequence[PostDb], |
61 | | - post_with_refs_and_tags: Tuple[MessageDb, PostDb], |
| 62 | + post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], |
62 | 63 | ): |
63 | | - message_db, post_db = post_with_refs_and_tags |
| 64 | + message_db, post_db, message_status_db = post_with_refs_and_tags |
64 | 65 |
|
65 | 66 | with session_factory() as session: |
66 | 67 | session.add_all(fixture_posts) |
67 | | - session.add(message_db) |
68 | | - session.add(post_db) |
| 68 | + session.add_all([message_db, post_db, message_status_db]) |
69 | 69 | session.commit() |
70 | 70 |
|
71 | 71 | # Match the ref |
@@ -113,20 +113,24 @@ async def test_get_amended_posts_refs( |
113 | 113 | ccn_api_client, |
114 | 114 | session_factory: DbSessionFactory, |
115 | 115 | fixture_posts: Sequence[PostDb], |
116 | | - post_with_refs_and_tags: Tuple[MessageDb, PostDb], |
117 | | - amended_post_with_refs_and_tags: Tuple[MessageDb, PostDb], |
| 116 | + post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], |
| 117 | + amended_post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], |
118 | 118 | ): |
119 | | - original_message_db, original_post_db = post_with_refs_and_tags |
120 | | - amend_message_db, amend_post_db = amended_post_with_refs_and_tags |
| 119 | + original_message_db, original_post_db, original_message_status_db = ( |
| 120 | + post_with_refs_and_tags |
| 121 | + ) |
| 122 | + amend_message_db, amend_post_db, amend_message_status_db = ( |
| 123 | + amended_post_with_refs_and_tags |
| 124 | + ) |
121 | 125 |
|
122 | 126 | original_post_db.latest_amend = amend_post_db.item_hash |
123 | 127 |
|
124 | 128 | with session_factory() as session: |
125 | 129 | session.add_all(fixture_posts) |
126 | | - session.add(original_message_db) |
127 | | - session.add(original_post_db) |
128 | | - session.add(amend_message_db) |
129 | | - session.add(amend_post_db) |
| 130 | + session.add_all( |
| 131 | + [original_message_db, original_post_db, original_message_status_db] |
| 132 | + ) |
| 133 | + session.add_all([amend_message_db, amend_post_db, amend_message_status_db]) |
130 | 134 | session.commit() |
131 | 135 |
|
132 | 136 | # Match the ref |
@@ -174,14 +178,13 @@ async def test_get_posts_tags( |
174 | 178 | ccn_api_client, |
175 | 179 | session_factory: DbSessionFactory, |
176 | 180 | fixture_posts: Sequence[PostDb], |
177 | | - post_with_refs_and_tags: Tuple[MessageDb, PostDb], |
| 181 | + post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], |
178 | 182 | ): |
179 | | - message_db, post_db = post_with_refs_and_tags |
| 183 | + message_db, post_db, message_status_db = post_with_refs_and_tags |
180 | 184 |
|
181 | 185 | with session_factory() as session: |
182 | 186 | session.add_all(fixture_posts) |
183 | | - session.add(message_db) |
184 | | - session.add(post_db) |
| 187 | + session.add_all([message_db, post_db, message_status_db]) |
185 | 188 | session.commit() |
186 | 189 |
|
187 | 190 | # Match one tag |
@@ -244,20 +247,24 @@ async def test_get_amended_posts_tags( |
244 | 247 | ccn_api_client, |
245 | 248 | session_factory: DbSessionFactory, |
246 | 249 | fixture_posts: Sequence[PostDb], |
247 | | - post_with_refs_and_tags: Tuple[MessageDb, PostDb], |
248 | | - amended_post_with_refs_and_tags: Tuple[MessageDb, PostDb], |
| 250 | + post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], |
| 251 | + amended_post_with_refs_and_tags: Tuple[MessageDb, PostDb, MessageStatusDb], |
249 | 252 | ): |
250 | | - original_message_db, original_post_db = post_with_refs_and_tags |
251 | | - amend_message_db, amend_post_db = amended_post_with_refs_and_tags |
| 253 | + original_message_db, original_post_db, original_message_status_db = ( |
| 254 | + post_with_refs_and_tags |
| 255 | + ) |
| 256 | + amend_message_db, amend_post_db, amend_message_status_db = ( |
| 257 | + amended_post_with_refs_and_tags |
| 258 | + ) |
252 | 259 |
|
253 | 260 | original_post_db.latest_amend = amend_post_db.item_hash |
254 | 261 |
|
255 | 262 | with session_factory() as session: |
256 | 263 | session.add_all(fixture_posts) |
257 | | - session.add(original_message_db) |
258 | | - session.add(original_post_db) |
259 | | - session.add(amend_message_db) |
260 | | - session.add(amend_post_db) |
| 264 | + session.add_all( |
| 265 | + [original_message_db, original_post_db, original_message_status_db] |
| 266 | + ) |
| 267 | + session.add_all([amend_message_db, amend_post_db, amend_message_status_db]) |
261 | 268 | session.commit() |
262 | 269 |
|
263 | 270 | # Match one tag |
|
0 commit comments