def test_utf8(): r = Result('ok', 200, title="£20") assert r.title == "£20" assert isinstance(r.title, str) assert str(r) == """<Result: status="ok" code="200" category="None" type="None" ip="None" body_length="0" """ \ """ssl_verified="None" ssl_fingerprint="None" final_url="None" resolved_ip="None" title="£20">"""
def test_initial_selftest_must_allow_site_blocked(probe, mock_url_tester, mock_probe_config): mock_url_tester.test_url.side_effect = None mock_url_tester.test_url.return_value = Result('blocked', 200) mock_probe_config['selftest'] = 'True' with raises(SelfTestError): probe().run_startup_selftest()
def test_unicode(): title = u"Some text here with a \u00a3 sign" r = Result('ok', 200, title=title) assert isinstance(title, unicode) assert r.title == "Some text here with a £ sign" assert isinstance(r.title, str) assert str(r) == """<Result: status="ok" code="200" category="None" type="None" ip="None" body_length="0" """ \ """ssl_verified="None" ssl_fingerprint="None" final_url="None" resolved_ip="None" title="Some text here with a £ sign">""" logging.info("result: %s", r)
def test_selftest_must_allow_site_blocked(mock_amqp_queue, probe, mock_url_tester): mock_url_tester.test_url.side_effect = None mock_url_tester.test_url.return_value = Result('blocked', 200) probe().run_test({ "action": "run_selftest", "request_id": "001" }) report = mock_amqp_queue.send_selftest_report.call_args[0][0] assert report["result"] == "error"
def test_url(url): if "must.block.fakedomain" in url: return Result('blocked', 200) else: return Result('ok', 200)
def test_response(self, response, body): return Result('ok', 200, title="title", body_length=1234)