mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-01-15 19:50:34 +00:00
Some checks failed
Build and push containers / metadata (push) Has been cancelled
Build and push containers / build-push-containers (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/amd64 (alpine) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm64 (alpine) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/amd64 (main) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm/v7 (main) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm/v8 (main) (push) Has been cancelled
ChangeDetection.io Container Build Test / Build linux/arm64 (main) (push) Has been cancelled
ChangeDetection.io App Test / lint-code (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Test the built package works basically. (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-10 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-11 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-12 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-13 (push) Has been cancelled
74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
# coding=utf-8
|
|
|
|
import time
|
|
from flask import url_for
|
|
from .util import live_server_setup, wait_for_all_checks, extract_UUID_from_client
|
|
import pytest
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
def set_html_response(datastore_path):
|
|
test_return_data = """
|
|
<html><body><span class="nav_second_img_text">
|
|
铸大国重器,挺制造脊梁,致力能源未来,赋能美好生活。
|
|
</span>
|
|
</body></html>
|
|
"""
|
|
with open(os.path.join(datastore_path, "endpoint-content.txt"), "w") as f:
|
|
f.write(test_return_data)
|
|
return None
|
|
|
|
|
|
# In the case the server does not issue a charset= or doesnt have content_type header set
|
|
def test_check_encoding_detection(client, live_server, measure_memory_usage, datastore_path):
|
|
set_html_response(datastore_path=datastore_path)
|
|
|
|
# Add our URL to the import page
|
|
test_url = url_for('test_endpoint', content_type="text/html", _external=True)
|
|
uuid = client.application.config.get('DATASTORE').add_watch(url=test_url)
|
|
client.get(url_for("ui.form_watch_checknow"), follow_redirects=True)
|
|
|
|
# Give the thread time to pick it up
|
|
wait_for_all_checks(client)
|
|
|
|
|
|
# Content type recording worked
|
|
uuid = next(iter(live_server.app.config['DATASTORE'].data['watching']))
|
|
assert live_server.app.config['DATASTORE'].data['watching'][uuid]['content-type'] == "text/html"
|
|
|
|
res = client.get(
|
|
url_for("ui.ui_preview.preview_page", uuid="first"),
|
|
follow_redirects=True
|
|
)
|
|
|
|
# Should see the proper string
|
|
assert "铸大国重".encode('utf-8') in res.data
|
|
# Should not see the failed encoding
|
|
assert b'\xc2\xa7' not in res.data
|
|
|
|
|
|
# In the case the server does not issue a charset= or doesnt have content_type header set
|
|
def test_check_encoding_detection_missing_content_type_header(client, live_server, measure_memory_usage, datastore_path):
|
|
set_html_response(datastore_path=datastore_path)
|
|
|
|
# Add our URL to the import page
|
|
test_url = url_for('test_endpoint', _external=True)
|
|
uuid = client.application.config.get('DATASTORE').add_watch(url=test_url)
|
|
client.get(url_for("ui.form_watch_checknow"), follow_redirects=True)
|
|
|
|
wait_for_all_checks(client)
|
|
|
|
res = client.get(
|
|
url_for("ui.ui_preview.preview_page", uuid="first"),
|
|
follow_redirects=True
|
|
)
|
|
|
|
# Should see the proper string
|
|
assert "铸大国重".encode('utf-8') in res.data
|
|
# Should not see the failed encoding
|
|
assert b'\xc2\xa7' not in res.data
|