Files
Luciano Gervasoni d18eda2fc4
Tests / test (pull_request) Failing after 3m11s
Add unit tests and Gitea CI workflow for bug fixes
- Add fetcher/tests/ with 21 tests covering all bug fixes:
  - test_utils: get_with_protocol URL normalization (5 tests)
  - test_config: scheduled_tasks.json PK uniqueness, Celery queue
    settings (7 tests)
  - test_publish: URL routing and view for /task/publish_<id>/ (4 tests)
  - test_template_field: url_detail.html renders images_url field (2 tests)
  - test_search_postprocess: URL host filtering and param stripping (3 tests)
- Replace empty fetcher/tests.py with tests/ package
- Add .gitea/workflows/test.yml: runs on PRs and pushes to main,
  installs dependencies and runs `manage.py test fetcher.tests`
2026-09-02 09:42:07 -03:00

23 lines
810 B
Python

from django.test import SimpleTestCase
from ..src.utils import get_with_protocol
class GetWithProtocolTests(SimpleTestCase):
def test_missing_protocol_prepends_https(self):
self.assertEqual(get_with_protocol("example.com"), "https://example.com")
def test_missing_protocol_with_path(self):
self.assertEqual(
get_with_protocol("example.com/article"),
"https://example.com/article",
)
def test_upgrades_http_to_https(self):
self.assertEqual(get_with_protocol("http://example.com"), "https://example.com")
def test_preserves_https(self):
self.assertEqual(get_with_protocol("https://example.com"), "https://example.com")
def test_empty_string_becomes_https(self):
self.assertEqual(get_with_protocol(""), "https://")