@ -1,7 +1,7 @@
import json
import time
from flask import url_for
from . util import set_original_response , set_modified_response , live_server_setup
from . util import set_original_response , set_modified_response , live_server_setup , wait_for_all_checks
def test_setup ( live_server ) :
live_server_setup ( live_server )
@ -234,3 +234,62 @@ def test_method_in_request(client, live_server):
# Should be only one with method set to PATCH
assert watches_with_method == 1
res = client . get ( url_for ( " form_delete " , uuid = " all " ) , follow_redirects = True )
assert b ' Deleted ' in res . data
def test_headers_textfile_in_request ( client , live_server ) :
# Add our URL to the import page
test_url = url_for ( ' test_headers ' , _external = True )
# Add the test URL twice, we will check
res = client . post (
url_for ( " import_page " ) ,
data = { " urls " : test_url } ,
follow_redirects = True
)
assert b " 1 Imported " in res . data
time . sleep ( 1 )
res = client . post (
url_for ( " import_page " ) ,
data = { " urls " : test_url } ,
follow_redirects = True
)
assert b " 1 Imported " in res . data
time . sleep ( 3 )
# Add some headers to a request
res = client . post (
url_for ( " edit_page " , uuid = " first " ) ,
data = {
" url " : test_url ,
" tag " : " " ,
" fetch_backend " : " html_requests " ,
" headers " : " xxx:ooo \n cool:yeah \r \n " } ,
follow_redirects = True
)
assert b " Updated watch. " in res . data
wait_for_all_checks ( client )
with open ( ' test-datastore/headers.txt ' , ' w ' ) as f :
f . write ( " global-header: nice \r \n next-global-header: nice " )
client . get ( url_for ( " form_watch_checknow " ) , follow_redirects = True )
# Give the thread time to pick it up
wait_for_all_checks ( client )
# The service should echo back the request verb
res = client . get (
url_for ( " preview_page " , uuid = " first " ) ,
follow_redirects = True
)
assert b " global-header: nice " in res . data
assert b " next-global-header: nice " in res . data
assert b " cool: yeah " in res . data
#unlink headers.txt on start/stop
res = client . get ( url_for ( " form_delete " , uuid = " all " ) , follow_redirects = True )
assert b ' Deleted ' in res . data