File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -73,4 +73,38 @@ def test_user_exist_not(client):
7373
7474 new_user = res .json ()
7575 new_user ['password' ] = user_data ['password' ]
76- return new_user
76+ return new_user
77+
78+
79+ @pytest .fixture
80+ def test_posts (test_user_exist , session , test_user_exist_not ):
81+ posts_data = [{
82+ "title" : "first title" ,
83+ "content" : "first content" ,
84+ "owner_id" : test_user_exist ['id' ]
85+ }, {
86+ "title" : "2nd title" ,
87+ "content" : "2nd content" ,
88+ "owner_id" : test_user_exist ['id' ]
89+ },
90+ {
91+ "title" : "3rd title" ,
92+ "content" : "3rd content" ,
93+ "owner_id" : test_user_exist ['id' ]
94+ }, {
95+ "title" : "3rd title" ,
96+ "content" : "3rd content" ,
97+ "owner_id" : test_user_exist2 ['id' ]
98+ }]
99+
100+ def create_post_model (post ):
101+ return models .Post (** post )
102+
103+ post_map = map (create_post_model , posts_data )
104+ posts = list (post_map )
105+
106+ session .add_all (posts )
107+ session .commit ()
108+
109+ posts = session .query (models .Post ).all ()
110+ return posts
You can’t perform that action at this time.
0 commit comments