99from typing import List
1010
1111from sqlalchemy import text
12+ from web3 import Web3
1213from web3 .datastructures import AttributeDict
1314
1415from integration_tests .challenges .index_helpers import UpdateTask
2223from src .tasks .entity_manager .entity_manager import entity_manager_update
2324from src .utils .db_session import get_db
2425
25- from web3 import Web3
26-
2726logger = logging .getLogger (__name__ )
2827
2928# Base entities shared across fan club post (text post) tests.
@@ -158,9 +157,9 @@ def test_create_fan_club_post(app, mocker):
158157 assert comments [0 ].entity_id == 1
159158 assert comments [0 ].user_id == 1
160159
161- notifications = session . query ( Notification ). filter (
162- Notification . type == "comment"
163- ). all ()
160+ notifications = (
161+ session . query ( Notification ). filter ( Notification . type == "comment" ). all ()
162+ )
164163 assert len (notifications ) == 0
165164
166165
@@ -169,12 +168,14 @@ def test_create_fan_club_post_invalid_no_artist_coin(app, mocker):
169168 Creating a fan club post for a user_id that has no artist coin should be
170169 silently skipped (validation error).
171170 """
172- bad_metadata = json .dumps ({
173- "entity_id" : 99 , # user 99 doesn't exist and has no coin
174- "entity_type" : "FanClub" ,
175- "body" : "should fail" ,
176- "parent_comment_id" : None ,
177- })
171+ bad_metadata = json .dumps (
172+ {
173+ "entity_id" : 99 , # user 99 doesn't exist and has no coin
174+ "entity_type" : "FanClub" ,
175+ "body" : "should fail" ,
176+ "parent_comment_id" : None ,
177+ }
178+ )
178179
179180 tx_receipts = {
180181 "BadFanClubPost" : [
@@ -223,11 +224,13 @@ def test_fan_club_post_reply(app, mocker):
223224 ],
224225 }
225226
226- reply_metadata = json .dumps ({
227- ** fan_club_post_metadata ,
228- "body" : "replying to your post" ,
229- "parent_comment_id" : 1 ,
230- })
227+ reply_metadata = json .dumps (
228+ {
229+ ** fan_club_post_metadata ,
230+ "body" : "replying to your post" ,
231+ "parent_comment_id" : 1 ,
232+ }
233+ )
231234
232235 tx_receipts = {
233236 "FanClubPostReply" : [
@@ -283,12 +286,14 @@ def test_fan_club_post_reply_non_owner_rejected(app, mocker):
283286 ],
284287 }
285288
286- cross_thread_metadata = json .dumps ({
287- "entity_id" : 1 ,
288- "entity_type" : "FanClub" ,
289- "body" : "cross-thread reply" ,
290- "parent_comment_id" : 1 , # parent is a Track comment, not fan club
291- })
289+ cross_thread_metadata = json .dumps (
290+ {
291+ "entity_id" : 1 ,
292+ "entity_type" : "FanClub" ,
293+ "body" : "cross-thread reply" ,
294+ "parent_comment_id" : 1 , # parent is a Track comment, not fan club
295+ }
296+ )
292297
293298 tx_receipts = {
294299 "CrossThreadReply" : [
@@ -537,11 +542,13 @@ def test_update_fan_club_post(app, mocker):
537542 ],
538543 }
539544
540- update_metadata = json .dumps ({
541- "entity_id" : 1 ,
542- "entity_type" : "FanClub" ,
543- "body" : "edited text" ,
544- })
545+ update_metadata = json .dumps (
546+ {
547+ "entity_id" : 1 ,
548+ "entity_type" : "FanClub" ,
549+ "body" : "edited text" ,
550+ }
551+ )
545552
546553 tx_receipts = {
547554 "EditFanClubPost" : [
@@ -578,11 +585,13 @@ def test_update_fan_club_post(app, mocker):
578585
579586def test_fan_club_post_with_mention (app , mocker ):
580587 """Mentions in a fan club text post generate mention notifications."""
581- mention_metadata = json .dumps ({
582- ** fan_club_post_metadata ,
583- "body" : "hey @user3 check this out" ,
584- "mentions" : [3 ],
585- })
588+ mention_metadata = json .dumps (
589+ {
590+ ** fan_club_post_metadata ,
591+ "body" : "hey @user3 check this out" ,
592+ "mentions" : [3 ],
593+ }
594+ )
586595
587596 tx_receipts = {
588597 "FanClubPostMention" : [
@@ -629,12 +638,14 @@ def test_fan_club_post_and_track_comments_coexist(app, mocker):
629638 Creating both a fan club post and a Track comment in the same block
630639 produces the correct entity_type on each and independent notifications.
631640 """
632- track_comment_metadata = json .dumps ({
633- "entity_id" : 1 ,
634- "entity_type" : "Track" ,
635- "body" : "great track!" ,
636- "parent_comment_id" : None ,
637- })
641+ track_comment_metadata = json .dumps (
642+ {
643+ "entity_id" : 1 ,
644+ "entity_type" : "Track" ,
645+ "body" : "great track!" ,
646+ "parent_comment_id" : None ,
647+ }
648+ )
638649
639650 tx_receipts = {
640651 "FanClubPost" : [
@@ -684,9 +695,9 @@ def test_fan_club_post_and_track_comments_coexist(app, mocker):
684695 assert track_comment .entity_id == 1
685696
686697 # Fan club owner self-post does not notify; track comment notifies track owner.
687- notifs = session . query ( Notification ). filter (
688- Notification . type == "comment"
689- ). all ()
698+ notifs = (
699+ session . query ( Notification ). filter ( Notification . type == "comment" ). all ()
700+ )
690701 assert len (notifs ) == 1
691702 assert notifs [0 ].group_id == "comment:1:type:Track"
692703
@@ -712,7 +723,9 @@ def _seed_coin_holders(session, artist_user_id=1, holder_user_ids=None, mint=COI
712723 session .flush ()
713724
714725
715- def test_fan_club_text_post_notification_sent_to_followers_and_coin_holders (app , mocker ):
726+ def test_fan_club_text_post_notification_sent_to_followers_and_coin_holders (
727+ app , mocker
728+ ):
716729 """
717730 When an artist creates a root-level fan club text post, both followers
718731 and coin holders receive a fan_club_text_post notification (deduplicated).
@@ -767,9 +780,7 @@ def test_fan_club_text_post_notification_sent_to_followers_and_coin_holders(app,
767780
768781 # No "comment" notification since artist is posting on their own fan club
769782 comment_notifs = (
770- session .query (Notification )
771- .filter (Notification .type == "comment" )
772- .all ()
783+ session .query (Notification ).filter (Notification .type == "comment" ).all ()
773784 )
774785 assert len (comment_notifs ) == 0
775786
@@ -835,11 +846,13 @@ def test_fan_club_text_post_notification_not_sent_for_replies(app, mocker):
835846 ],
836847 }
837848
838- reply_metadata = json .dumps ({
839- ** fan_club_post_metadata ,
840- "body" : "replying to my own post" ,
841- "parent_comment_id" : 1 ,
842- })
849+ reply_metadata = json .dumps (
850+ {
851+ ** fan_club_post_metadata ,
852+ "body" : "replying to my own post" ,
853+ "parent_comment_id" : 1 ,
854+ }
855+ )
843856
844857 tx_receipts = {
845858 "ArtistReply" : [
0 commit comments