Ticket: Delete Comments

Hello,

I am trying to resolve Delete Comments ticket, unfortunately I have faced an issue.
Pytest tests passed.

It is how my delete_comment function looks:

Passed tests:

post_data and user_email are printed to investigate a problem (print(post_data, user_email)) in api_post_comment, api_update_comment and api_delete_comment.

In my opinion, everything works fine, because, firstly two comments are posted, secondly it is checked if comment can be edited and deleted with different email, eventually it is edited and deleted with correct email. Those booleans (0, 1) above DELETE requests are ‘deleted_count’ method executed to delete request’s response. So, it is also correct in my opinion.

Unfortunately, in status page I have got sth like:

Could you help with it?

I got the same error while working with nodejs, but the error seems to be the same.

I had another issue: tests did not pass, because I did not have any changes in function, but the status page showed a correct hash.

@Aa_77247 Yes, I have also noticed this issue. Now, I can’t reproduce it, but I am sure, status page has shown hash for Delete Comments before making Create/Update Comments ticket.

1 Like

It seems, it works for me now.
Eventually, I have not changed nothing in code. In the meantime I tried a lot of things to make it passed. The last thing, after which it works was manually defining comment_id and user_email in delete_comment using those values from pytest’s test. Test with those values in status page have failed, but after restore version with dynamically defined comment_id and user_email, test in status page is passed. I don’t know, whether it means sth. It is only for your info.

This solved for me:

response = db.comments.delete_one( {"$and":[{ “_id”: ObjectId(comment_id)},{“email”:user_email}]})

The $and operator make the conjunction of the two queries “_id” and “email”

Which would be equivalent to simply { “_id”: ObjectId(comment_id),“email”:user_email }. This being said, please follow forum guidelines and do not post answers.

Please also note that this thread is 29 days old. Most participants are not here anymore.


This is my code. Can’t figure out why it fails the test.