Skip to content

R35-T036: Simplify one responsibility in connection (insta_down.py) - #66

Closed
suraj-3010 wants to merge 1 commit into
S-AI-Projects:mainfrom
suraj-3010:student/e26b07f1007/R35-T036
Closed

suraj-3010 wants to merge 1 commit into
S-AI-Projects:mainfrom
suraj-3010:student/e26b07f1007/R35-T036

Conversation

@suraj-3010

Copy link
Copy Markdown

Description

This PR refactors connection in InstaDownloader/insta_down.py by extracting the network reachability check and exception categorization into a dedicated subroutine check_url_reachability, separating network probing from terminal output while strictly preserving the public function signature and behavior.

Related Issue

Fixes: #36

Type of Change

  • Bug Fix
  • New Feature
  • UI/UX Improvement
  • Performance Improvement
  • Tests
  • Documentation
  • Refactoring / Maintenance
  • CI/CD

Changes Made

  • Extracted network probe execution and exception classification from connection into check_url_reachability(url, timeout) returning (is_connected, message).
  • Preserved the existing connection(url='http://www.google.com/', timeout=5) contract and stdout printing behavior.
  • Guarded the interactive user prompt loop under if __name__ == '__main__': and added safe import handling for instaloader.
  • Added unit tests in InstaDownloader/test_insta_down.py validating smallest valid input, ordinary input, and error response paths with mocked requests.
  • Added work/R35-T036/check.py runner and work/R35-T036/evidence.md.

Screenshots / Recordings

There is no UI change.

Testing

  1. Ran python3 work/R35-T036/check.py: PASS (all checks, smallest input, ordinary input, and 4 unittest cases passed).
  2. Ran FORCE_WRONG=1 python3 work/R35-T036/check.py: FAIL (exited with code 1 upon deliberate value mismatch).
  3. Ran python3 -m unittest "InstaDownloader/test_insta_down.py": PASS (4 tests ran in 0.001s, OK).

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes

Evidence and check artifacts are recorded under work/R35-T036/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant