Refactor test fixtures to use shared create_args helper

Uses the real parse_args() function to get CLI defaults, so when
new arguments are added they're automatically available to all tests.

Changes:
- Add tests/conftest.py with create_args fixture
- Update 8 test files to use shared fixture
- Remove duplicate _create_mock_args methods
- Remove redundant @pytest.fixture mock_args definitions

This eliminates the need to update multiple test files when
adding new CLI arguments.
This commit is contained in:
Rodos
2026-01-13 13:43:45 +11:00
parent fce4abb74a
commit ab0eebb175
9 changed files with 158 additions and 355 deletions

View File

@@ -11,17 +11,9 @@ from github_backup import github_backup
class TestHTTP451Exception:
"""Test suite for HTTP 451 DMCA takedown exception handling."""
def test_repository_unavailable_error_raised(self):
def test_repository_unavailable_error_raised(self, create_args):
"""HTTP 451 should raise RepositoryUnavailableError with DMCA URL."""
args = Mock()
args.as_app = False
args.token_fine = None
args.token_classic = None
args.osx_keychain_item_name = None
args.osx_keychain_item_account = None
args.throttle_limit = None
args.throttle_pause = 0
args.max_retries = 5
args = create_args()
mock_response = Mock()
mock_response.getcode.return_value = 451
@@ -53,17 +45,9 @@ class TestHTTP451Exception:
)
assert "451" in str(exc_info.value)
def test_repository_unavailable_error_without_dmca_url(self):
def test_repository_unavailable_error_without_dmca_url(self, create_args):
"""HTTP 451 without DMCA details should still raise exception."""
args = Mock()
args.as_app = False
args.token_fine = None
args.token_classic = None
args.osx_keychain_item_name = None
args.osx_keychain_item_account = None
args.throttle_limit = None
args.throttle_pause = 0
args.max_retries = 5
args = create_args()
mock_response = Mock()
mock_response.getcode.return_value = 451
@@ -83,17 +67,9 @@ class TestHTTP451Exception:
assert exc_info.value.dmca_url is None
assert "451" in str(exc_info.value)
def test_repository_unavailable_error_with_malformed_json(self):
def test_repository_unavailable_error_with_malformed_json(self, create_args):
"""HTTP 451 with malformed JSON should still raise exception."""
args = Mock()
args.as_app = False
args.token_fine = None
args.token_classic = None
args.osx_keychain_item_name = None
args.osx_keychain_item_account = None
args.throttle_limit = None
args.throttle_pause = 0
args.max_retries = 5
args = create_args()
mock_response = Mock()
mock_response.getcode.return_value = 451