forked from pixee/codemodder-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_https_connection.py
More file actions
79 lines (57 loc) · 2.12 KB
/
test_https_connection.py
File metadata and controls
79 lines (57 loc) · 2.12 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from codemodder.codemods.test import BaseCodemodTest
from core_codemods.https_connection import HTTPSConnection
class TestHTTPSConnection(BaseCodemodTest):
codemod = HTTPSConnection
def test_no_change(self, tmpdir):
before = r"""import urllib3
urllib3.HTTPSConnectionPool("localhost", "80")
"""
self.run_and_assert(tmpdir, before, before)
def test_simple(self, tmpdir):
before = r"""import urllib3
urllib3.HTTPConnectionPool("localhost", "80")
"""
after = r"""import urllib3
urllib3.HTTPSConnectionPool("localhost", "80")
"""
self.run_and_assert(tmpdir, before, after)
def test_module_alias(self, tmpdir):
before = r"""import urllib3 as module
module.HTTPConnectionPool("localhost", "80")
"""
after = r"""import urllib3 as module
module.HTTPSConnectionPool("localhost", "80")
"""
self.run_and_assert(tmpdir, before, after)
def test_alias(self, tmpdir):
before = r"""from urllib3 import HTTPConnectionPool as something
something("localhost", "80")
"""
after = r"""import urllib3
urllib3.HTTPSConnectionPool("localhost", "80")
"""
self.run_and_assert(tmpdir, before, after)
def test_connectionpool(self, tmpdir):
before = r"""import urllib3
urllib3.connectionpool.HTTPConnectionPool("localhost", "80")
"""
after = r"""import urllib3
urllib3.connectionpool.HTTPSConnectionPool("localhost", "80")
"""
self.run_and_assert(tmpdir, before, after)
def test_connectionpool_alias(self, tmpdir):
before = r"""import urllib3.connectionpool as pool
pool.HTTPConnectionPool("localhost", "80")
"""
after = r"""import urllib3.connectionpool as pool
pool.HTTPSConnectionPool("localhost", "80")
"""
self.run_and_assert(tmpdir, before, after)
def test_last_arg(self, tmpdir):
before = r"""import urllib3
urllib3.HTTPConnectionPool(None, None, None, None, None, None, None, None, None, None)
"""
after = r"""import urllib3
urllib3.HTTPSConnectionPool(None, None, None, None, None, None, None, None, None, _proxy_config = None)
"""
self.run_and_assert(tmpdir, before, after)