@@ -65,15 +65,18 @@ def post_url(self, url, data):
65
65
proxies = server .proxy_dict ,
66
66
verify = TEST_CA_ROOT )
67
67
68
+ def _test_basic (self , resp , url ):
69
+ assert resp .status_code == 200
70
+ assert 'Content-Length' in resp .headers
71
+ assert resp .url == url
72
+
68
73
def test_replay_no_coll (self ):
69
74
resp = self .get_url ('https://iana.org/' )
70
- assert resp .url == 'https://select.pywb.proxy/https://iana.org/'
71
- assert resp .status_code == 200
75
+ self ._test_basic (resp , 'https://select.pywb.proxy/https://iana.org/' )
72
76
73
77
def test_replay_set_older_coll (self ):
74
78
resp = self .get_url ('https://older-set.pywb.proxy/https://iana.org/' )
75
- assert resp .url == 'https://iana.org/'
76
- assert resp .status_code == 200
79
+ self ._test_basic (resp , 'https://iana.org/' )
77
80
assert '20140126200624' in resp .text
78
81
79
82
sesh1 = self .session .cookies .get ('__pywb_proxy_sesh' , domain = '.pywb.proxy' )
@@ -89,15 +92,13 @@ def test_replay_set_older_coll(self):
89
92
90
93
def test_replay_same_coll (self ):
91
94
resp = self .get_url ('https://iana.org/' )
92
- assert resp .url == 'https://iana.org/'
93
- assert resp .status_code == 200
95
+ self ._test_basic (resp , 'https://iana.org/' )
94
96
assert 'wbinfo.proxy_magic = "pywb.proxy";' in resp .text
95
97
assert '20140126200624' in resp .text
96
98
97
99
def test_replay_set_change_coll (self ):
98
100
resp = self .get_url ('https://all-set.pywb.proxy/https://iana.org/' )
99
- assert resp .url == 'https://iana.org/'
100
- assert resp .status_code == 200
101
+ self ._test_basic (resp , 'https://iana.org/' )
101
102
assert '20140127171238' in resp .text
102
103
103
104
# verify still same session cookie
@@ -107,8 +108,7 @@ def test_replay_set_change_coll(self):
107
108
108
109
def test_query (self ):
109
110
resp = self .get_url ('https://query.pywb.proxy/*/https://iana.org/' )
110
- assert resp .url == 'https://query.pywb.proxy/*/https://iana.org/'
111
- assert resp .status_code == 200
111
+ self ._test_basic (resp , 'https://query.pywb.proxy/*/https://iana.org/' )
112
112
assert 'text/html' in resp .headers ['content-type' ]
113
113
assert '20140126200624' in resp .text
114
114
assert '20140127171238' in resp .text
@@ -117,35 +117,31 @@ def test_query(self):
117
117
# testing via http here
118
118
def test_change_timestamp (self ):
119
119
resp = self .get_url ('http://query.pywb.proxy/20140126200624/http://iana.org/' )
120
- assert resp .url == 'http://iana.org/'
121
- assert resp .status_code == 200
120
+ self ._test_basic (resp , 'http://iana.org/' )
122
121
assert '20140126200624' in resp .text
123
122
124
123
def test_change_coll_same_ts (self ):
125
124
resp = self .get_url ('https://all-set.pywb.proxy/iana.org/' )
126
- assert resp .url == 'https://iana.org/'
127
- assert resp .status_code == 200
125
+ self ._test_basic (resp , 'https://iana.org/' )
128
126
assert '20140126200624' in resp .text
129
127
130
128
# testing via http here
131
129
def test_change_latest_ts (self ):
132
130
resp = self .get_url ('http://query.pywb.proxy/http://iana.org/?_=1234' )
133
- assert resp .url == 'http://iana.org/?_=1234'
134
- assert resp .status_code == 200
131
+ self ._test_basic (resp , 'http://iana.org/?_=1234' )
135
132
assert '20140127171238' in resp .text
136
133
137
134
def test_diff_url (self ):
138
135
resp = self .get_url ('https://example.com/' )
139
- assert resp . url == 'https://example.com/'
136
+ self . _test_basic ( resp , 'https://example.com/' )
140
137
assert '20140127171251' in resp .text
141
138
142
139
@pytest .mark .skipif (sys .version_info < (2 ,7 ),
143
140
reason = "doesn't work in 2.6" )
144
141
def test_post_replay_all_coll (self ):
145
142
resp = self .post_url ('https://httpbin.org/post' , data = {'foo' : 'bar' , 'test' : 'abc' })
146
- assert resp . url == 'https://httpbin.org/post'
143
+ self . _test_basic ( resp , 'https://httpbin.org/post' )
147
144
assert 'application/json' in resp .headers ['content-type' ]
148
- assert resp .status_code == 200
149
145
150
146
# Bounce back to select.pywb.proxy due to missing session
151
147
def test_clear_key (self ):
@@ -155,19 +151,19 @@ def test_clear_key(self):
155
151
156
152
def test_no_sesh_latest_bounce (self ):
157
153
resp = self .get_url ('https://query.pywb.proxy/https://iana.org/' )
158
- assert resp . url == 'https://select.pywb.proxy/https://iana.org/'
154
+ self . _test_basic ( resp , 'https://select.pywb.proxy/https://iana.org/' )
159
155
160
156
def test_no_sesh_coll_change_bounce (self ):
161
157
resp = self .get_url ('https://auto.pywb.proxy/https://iana.org/' )
162
- assert resp . url == 'https://select.pywb.proxy/https://iana.org/'
158
+ self . _test_basic ( resp , 'https://select.pywb.proxy/https://iana.org/' )
163
159
164
160
def test_no_sesh_ts_bounce (self ):
165
161
resp = self .get_url ('https://query.pywb.proxy/20140126200624/https://iana.org/' )
166
- assert resp . url == 'https://select.pywb.proxy/20140126200624/https://iana.org/'
162
+ self . _test_basic ( resp , 'https://select.pywb.proxy/20140126200624/https://iana.org/' )
167
163
168
164
def test_no_sesh_query_bounce (self ):
169
165
resp = self .get_url ('https://query.pywb.proxy/*/https://iana.org/' )
170
- assert resp . url == 'https://select.pywb.proxy/https://query.pywb.proxy/*/https://iana.org/'
166
+ self . _test_basic ( resp , 'https://select.pywb.proxy/https://query.pywb.proxy/*/https://iana.org/' )
171
167
172
168
# static replay
173
169
def test_replay_static (self ):
0 commit comments