paijo77 commited on
Commit
f472a48
·
verified ·
1 Parent(s): bbc4356

update tests/integration/test_grabber_integration.py

Browse files
tests/integration/test_grabber_integration.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ import os
3
+ from app.grabber.github_grabber import GitHubGrabber
4
+ from app.models.source import SourceConfig, SourceType
5
+
6
+
7
+ class TestGrabberIntegration:
8
+ @pytest.mark.asyncio
9
+ async def test_extract_from_fixture_http(self):
10
+ fixture_path = os.path.join(
11
+ os.path.dirname(__file__), "../fixtures/github_raw_http.txt"
12
+ )
13
+
14
+ with open(fixture_path, "r") as f:
15
+ content = f.read()
16
+
17
+ grabber = GitHubGrabber()
18
+
19
+ proxies = await grabber.parse_content(content, SourceType.GITHUB_RAW)
20
+
21
+ assert len(proxies) >= 4
22
+ assert all(p.protocol == "http" for p in proxies)
23
+ assert all(1 <= p.port <= 65535 for p in proxies)
24
+
25
+ @pytest.mark.asyncio
26
+ async def test_extract_from_fixture_mixed(self):
27
+ fixture_path = os.path.join(
28
+ os.path.dirname(__file__), "../fixtures/github_raw_mixed.txt"
29
+ )
30
+
31
+ with open(fixture_path, "r") as f:
32
+ content = f.read()
33
+
34
+ grabber = GitHubGrabber()
35
+ proxies = await grabber.parse_content(content, SourceType.GENERIC_TEXT)
36
+
37
+ protocols = {p.protocol for p in proxies}
38
+
39
+ assert "http" in protocols
40
+ assert len(proxies) >= 3
41
+
42
+ @pytest.mark.asyncio
43
+ async def test_base64_subscription_fixture(self):
44
+ fixture_path = os.path.join(
45
+ os.path.dirname(__file__), "../fixtures/subscription_vmess.txt"
46
+ )
47
+
48
+ with open(fixture_path, "r") as f:
49
+ content = f.read().strip()
50
+
51
+ grabber = GitHubGrabber()
52
+ proxies = await grabber.parse_content(content, SourceType.SUBSCRIPTION_BASE64)
53
+
54
+ assert len(proxies) >= 1
55
+
56
+ @pytest.mark.integration
57
+ @pytest.mark.asyncio
58
+ async def test_real_github_url_skip(self):
59
+ pytest.skip("Real URL test - run with: pytest -m integration")