Skip to content

Latest commit

 

History

History
 
 

README.md

Offline test suite

These tests cover the pure and offline-safe logic of instagram_monitor.py. They never reach the network: the handful of functions that would normally contact Instagram are stubbed (see test_session_flags.py).

Running

From the repository root:

pip install -e '.[test]'
python -m pytest

pyproject.toml configures pytest to put the repository root first on sys.path (and conftest.py enforces it), so the tests always run against the working tree rather than any installed copy of the package.

Layout

File Area under test
test_config_generation.py Config inline-comment splitting, value formatting, generate_config_with_current_values round-trip
test_time_and_dates.py display_time, calculate_timespan, hour formatting, timezone conversions
test_privacy.py apply_privacy_substitutions (string/dict/list recursion, invalid entries)
test_notifications.py Webhook URL validation, Discord markdown escaping, credential masking, payload templating
test_scheduling.py CHECK_POSTS_IN_HOURS_RANGE window logic, next-check computation, cycle probability, interval randomization
test_session_flags.py Error classification and session/IP flag detection with a stubbed profile resolver
test_parsing_and_useragents.py JSON username extraction, follow-string formatting, desktop/mobile user-agent shape
test_csv_and_files.py CSV init/append and byte-wise image comparison
test_followers.py Follower/following diffing, webhook escaping, CSV side effects

Conventions

  • Module-level globals the helpers read are reset to a deterministic baseline by the autouse deterministic_globals fixture in conftest.py. Override them per test with monkeypatch.setattr(im_module, "NAME", value).
  • Use the im_module fixture to access the imported module.
  • Keep everything offline. If a code path needs network access, stub it with monkeypatch rather than skipping the test.

Online tests that log into Instagram are intentionally excluded, since automated logins risk triggering challenges or account suspension.