Skip to content

Commit d9dc557

Browse files
committed
added the create posts fixture
1 parent 253cf78 commit d9dc557

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

test/conftest.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff 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

test/test_posts.py

Whitespace-only changes.

0 commit comments

Comments
 (0)