Skip to content

tests: cover login and credential-storage edge branches - #5

Merged
josephrich98 merged 1 commit into
pachterlab:mainfrom
Faycall1l:tests/login-credentials-coverage
Sep 18, 2026
Merged

josephrich98 merged 1 commit into
pachterlab:mainfrom
Faycall1l:tests/login-credentials-coverage

Conversation

@Faycall1l

Copy link
Copy Markdown
Contributor

Summary

Adds unit tests for the two lowest-coverage files in the codebase, paperpush/venues/login.py (+32 tests, 52% → 94%) and paperpush/credentials.py (69% → 98%), using the existing fake-playwright test infrastructure (_FakePage/_FakeLocator). No production code changes; a venv-free, hermetic test-only PR.

What's covered

verify_login driver (tests/test_login.py)

  • Successful sign-in saves the session and closes the browser.
  • headless= is passed through to the venue's login.
  • The ORCID branch (method="orcid") passes orcid=True down; refused when the venue lacks supports_orcid_login (same orcid_unsupported message the submission path produces).
  • No automated sign-in available → LoginVerificationError naming the venue.
  • Headless failure → LoginVerificationError with the underlying cause; headed failure → prompt for a human, re-check, then save only if logged in.
  • Sign-in that does not take → LoginVerificationError("...did not take...").
  • NotImplementedError from the venue propagates unchanged.

paperpush/credentials.py (keyring + file store)

  • save_credential: writes to keyring with service name paperpush:<slug>; falls back to the file store when the keyring rejects a write or a read.
  • get_credential/delete_credential: clear keyring + file store; incomplete keyring entry / corrupt file store treated as absent/empty.
  • _get_keyring branch coverage: keyring module missing (ImportError), backend lookup failure, failing backend, working backend.

paperpush/venues/login.py helpers

  • first_present / first_visible fast/slow paths.
  • fill_login_form (shared by the login page): success and missing-control VenueLoginError.
  • login_orcid: popup control absent and ORCID form field missing → clean popup close.

Validation

  • pytest: 1382 passed / 74 skipped (was 1350); all portal tests still skipped by default; zero network or OS-keyring access (fixtures are additive only).
  • black . -l 99999 --check: clean.
  • All four generated-content checks remain green (gen_readme_venues.py, gen_venues_schema.py, gen_schema_docs.py, gen_subfile_templates.py) — no generated files touched.
  • Verified on Python 3.10 locally.

Cover the lowest-coverage paths in paperpush/venues/login.py and
paperpush/credentials.py: verify_login driver behavior (headless/headed,
ORCID, human fallback), the login_form helpers, and the many keyring /
file-store branches of save_credential / get_credential / _get_keyring.
@josephrich98
josephrich98 merged commit 8d86bac into pachterlab:main Sep 18, 2026
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.

2 participants