MCPcopy
hub / github.com/FlareSolverr/FlareSolverr / TestFlareSolverr

Class TestFlareSolverr

src/tests.py:18–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18class TestFlareSolverr(unittest.TestCase):
19
20 proxy_url = "http://127.0.0.1:8888"
21 proxy_socks_url = "socks5://127.0.0.1:1080"
22 google_url = "https://www.google.com"
23 post_url = "https://httpbin.org/post"
24 cloudflare_url = "https://nowsecure.nl/"
25 cloudflare_url_2 = "https://idope.se/torrent-list/harry/"
26 ddos_guard_url = "https://www.litres.ru/"
27 fairlane_url = "https://www.pararius.com/apartments/amsterdam"
28 custom_cloudflare_url = "https://www.muziekfabriek.org/"
29 cloudflare_blocked_url = "https://cpasbiens3.fr/index.php?do=search&subaction=search"
30
31 app = TestApp(flaresolverr.app)
32 # wait until the server is ready
33 app.get('/')
34
35 def test_wrong_endpoint(self):
36 res = self.app.get('/wrong', status=404)
37 self.assertEqual(res.status_code, 404)
38
39 body = res.json
40 self.assertEqual("Not found: '/wrong'", body['error'])
41 self.assertEqual(404, body['status_code'])
42
43 def test_index_endpoint(self):
44 res = self.app.get('/')
45 self.assertEqual(res.status_code, 200)
46
47 body = IndexResponse(res.json)
48 self.assertEqual("FlareSolverr is ready!", body.msg)
49 self.assertEqual(utils.get_flaresolverr_version(), body.version)
50 self.assertIn("Chrome/", body.userAgent)
51
52 def test_health_endpoint(self):
53 res = self.app.get('/health')
54 self.assertEqual(res.status_code, 200)
55
56 body = HealthResponse(res.json)
57 self.assertEqual(STATUS_OK, body.status)
58
59 def test_v1_endpoint_wrong_cmd(self):
60 res = self.app.post_json('/v1', {
61 "cmd": "request.bad",
62 "url": self.google_url
63 }, status=500)
64 self.assertEqual(res.status_code, 500)
65
66 body = V1ResponseBase(res.json)
67 self.assertEqual(STATUS_ERROR, body.status)
68 self.assertEqual("Error: Request parameter 'cmd' = 'request.bad' is invalid.", body.message)
69 self.assertGreater(body.startTimestamp, 10000)
70 self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
71 self.assertEqual(utils.get_flaresolverr_version(), body.version)
72
73 def test_v1_endpoint_request_get_no_cloudflare(self):
74 res = self.app.post_json('/v1', {
75 "cmd": "request.get",

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected