Skip to content

Fix api.py logic for corrupt cookie jar and added test cases for the same#1085

Open
arnchlmcodes wants to merge 2 commits intoopenzim:mainfrom
arnchlmcodes:fixes-issue-#443
Open

Fix api.py logic for corrupt cookie jar and added test cases for the same#1085
arnchlmcodes wants to merge 2 commits intoopenzim:mainfrom
arnchlmcodes:fixes-issue-#443

Conversation

@arnchlmcodes
Copy link
Copy Markdown
Contributor

@arnchlmcodes arnchlmcodes commented Feb 24, 2026

Added a try/except so if the cookie file is broken or corrupted, it deletes it so the program can start fresh.

also added two tests in api_test.py, one to verify that the error handling works and the file gets deleted if it's corrupt and the other test to verify the recovery works and the bot continues and logs in.

ran the ci pipeline locally and made sure everything works.

closes #443

Copy link
Copy Markdown
Member

@audiodude audiodude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow sorry, this fell off my radar. Sorry about that. The code looks good but I'm worried about the tests.

@arnchlmcodes
Copy link
Copy Markdown
Contributor Author

Could you please tell me what concerns you have regarding the tests, happy to address it right away,
Is it that the new test cases are almost similar, I split them into two separate tests to keep each test focused on one thing, one for the deletion and one for the login recovery, but I can merge them if you'd prefer that.

Comment thread wp1/api_test.py
Comment thread wp1/api_test.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (833f3da) to head (1848bb0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1085   +/-   ##
=======================================
  Coverage   93.00%   93.01%           
=======================================
  Files          76       76           
  Lines        4430     4436    +6     
=======================================
+ Hits         4120     4126    +6     
  Misses        310      310           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@audiodude audiodude enabled auto-merge April 26, 2026 21:27
@arnchlmcodes arnchlmcodes requested a review from audiodude April 28, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle the case when the cookiejar become corrupted

2 participants