@@ -26,6 +26,10 @@ def test_skip_urls_with_inner_params(self):
26
26
actual = list (self .extractor .extract_urls ('aaa http://www.{{param}}.com aaa' ))
27
27
self .assertEqual ([], actual )
28
28
29
+ def test_skip_urls_with_inner_variables (self ):
30
+ actual = list (self .extractor .extract_urls ('aaa http://www.{param}.com aaa' ))
31
+ self .assertEqual ([], actual )
32
+
29
33
30
34
class TestTxt (AsyncTestCase ):
31
35
def setUp (self ):
@@ -83,11 +87,17 @@ def test_skip_parameterized_urls_from_start(self, mock_get):
83
87
84
88
self .assertFalse (mock_get .called )
85
89
90
+ @patch ('aiohttp.request' )
91
+ def test_skip_urls_with_variables (self , mock_get ):
92
+ self ._check (mock_get , 'aaa http://domain.com/{ticket.url}, aaa' , 200 )
93
+
94
+ self .assertFalse (mock_get .called )
95
+
86
96
@patch ('aiohttp.request' )
87
97
def test_include_params_in_the_url (self , mock_get ):
88
98
self ._check (mock_get , 'aaa http://domain.com/hello?id=123 aaa' , 200 )
89
99
90
- mock_get .assert_called_with ('get' , 'http://domain.com/hello?id=123' , headers = self .headers )
100
+ mock_get .assert_called_with ('get' , 'http://domain.com/hello?id=123' , allow_redirects = True , headers = self .headers )
91
101
92
102
@patch ('aiohttp.request' )
93
103
def test_skip_empty_urls (self , mock_get ):
@@ -111,13 +121,13 @@ def test_skip_commas(self, mock_get):
111
121
def test_skip_commas_url (self , mock_get ):
112
122
self ._check (mock_get , 'aaa http://www.google.com, aaa' , 200 )
113
123
114
- mock_get .assert_called_with ('get' , 'http://www.google.com' , headers = self .headers )
124
+ mock_get .assert_called_with ('get' , 'http://www.google.com' , allow_redirects = True , headers = self .headers )
115
125
116
126
@patch ('aiohttp.request' )
117
127
def test_skip_chineese_commas (self , mock_get ):
118
128
self ._check (mock_get , 'aaa http://bit.ly/UpdateKeepSafe。拥有最新版本就能解决大部分问题了。 aaa' , 200 )
119
129
120
- mock_get .assert_called_with ('get' , 'http://bit.ly/UpdateKeepSafe' , headers = self .headers )
130
+ mock_get .assert_called_with ('get' , 'http://bit.ly/UpdateKeepSafe' , allow_redirects = True , headers = self .headers )
121
131
122
132
@patch ('aiohttp.request' )
123
133
def test_skip_keepsafe_urls (self , mock_get ):
@@ -127,10 +137,10 @@ def test_skip_keepsafe_urls(self, mock_get):
127
137
128
138
@patch ('aiohttp.request' )
129
139
def test_check_headers (self , mock_get ):
130
- self .check = url .UrlValidator ('txt' , headers = self .headers )
140
+ self .check = url .UrlValidator ('txt' , allow_redirects = True , headers = self .headers )
131
141
self ._check (mock_get , 'aaa http://www.google.com, aaa' , 200 )
132
142
133
- mock_get .assert_called_with ('get' , 'http://www.google.com' , headers = self .headers )
143
+ mock_get .assert_called_with ('get' , 'http://www.google.com' , allow_redirects = True , headers = self .headers )
134
144
135
145
136
146
class TestHtml (AsyncTestCase ):
@@ -154,7 +164,7 @@ def _check(self, mock_get, content, status_code, check=None):
154
164
def test_happy_path (self , mock_get ):
155
165
errors = self ._check (mock_get , '<a href="http://www.google.com">link</a>' , 200 )
156
166
157
- mock_get .assert_called_with ('get' , 'http://www.google.com' , headers = self .headers )
167
+ mock_get .assert_called_with ('get' , 'http://www.google.com' , allow_redirects = True , headers = self .headers )
158
168
self .assertEqual ([], errors )
159
169
160
170
@patch ('aiohttp.request' )
0 commit comments