Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete pytest #54

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions backend/test/services/post_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Mock Models
user = User(id=1, pid=111111111, onyen='onyen',first_name="first", last_name = "last", email='[email protected]', pronouns="He/Him/His", permissions = [])

post_0 = Post(id = 1, content = "post", user = user, votes = [], timestamp = "date0")
post_1 = Post(id = 2, content = "content", user = user, votes = [], timestamp = "date1")
post_0 = Post(id = 1, title = "title", content = "post", user = user, votes = [], timestamp = "date0")
post_1 = Post(id = 2, title = "title", content = "content", user = user, votes = [], timestamp = "date1")

@pytest.fixture(autouse=True)
def setup_teardown(test_session: Session):
Expand Down Expand Up @@ -46,5 +46,13 @@ def test_getall_posts_pass(postservice: PostService, userservice: UserService):
post_entity_0: Post = postservice.create(post_0, user_entity)
post_entity_1: Post = postservice.create(post_1, user_entity)
posts = postservice.getAll()
assert posts[0] == post_0
assert posts[1] == post_1
assert posts[0] == post_entity_0
assert posts[1] == post_entity_1

def test_delete_post_pass(postservice: PostService, userservice: UserService):
user_entity: UserEntity = userservice.findUser(user)
wastilla marked this conversation as resolved.
Show resolved Hide resolved
post_entity_0: Post = postservice.create(post_0, user_entity)
post_entity_1: Post = postservice.create(post_1, user_entity)
postservice.delete(post_entity_0.id)
posts = postservice.getAll()
assert posts[0] == post_entity_1