-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_generates_uri.py
32 lines (28 loc) · 992 Bytes
/
test_generates_uri.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
import subprocess
import json
from pathlib import Path
class TestScript(unittest.TestCase):
def setUp(self):
self.config_path = 'test_config.json'
sample_config = {
"remarks": "ShadowSocks Server",
"server":"github.com",
"server_port":8388,
"password":"fake_pwd",
"method":"chacha20-ietf-poly1305"
}
with open(self.config_path, 'w') as f:
json.dump(sample_config, f)
def tearDown(self):
if Path(self.config_path).exists():
Path(self.config_path).unlink()
def test_generate_uri(self):
result = subprocess.run(
['python3', 'ss-genuri.py', '--config', self.config_path],
capture_output=True,
text=True
)
self.assertEqual('ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpmYWtlX3B3ZEBnaXRodWIuY29tOjgzODg=#ShadowSocks%20Server\n', result.stdout)
if __name__ == '__main__':
unittest.main()