# Path: xpaw/http.py
# class HttpRequest:
# class HttpResponse:
#     def __init__(self, url, method="GET", body=None, params=None, headers=None, proxy=None,
#                  timeout=20, verify_ssl=False, allow_redirects=True, auth=None, proxy_auth=None,
#                  priority=None, dont_filter=False, callback=None, errback=None, meta=None,
#                  render=None):
#     def __str__(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):
#     def to_dict(self):
#     def from_dict(cls, d):
#     def __init__(self, url, status, body=None, headers=None,
#                  request=None, encoding=None):
#     def __str__(self):
#     def encoding(self):
#     def encoding(self, value):
#     def text(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):
# 
# Path: xpaw/utils.py
# def get_params_in_url(url):
#     return parse_qs(urlsplit(url).query)


from xpaw.http import HttpRequest, HttpResponse, HttpHeaders
from xpaw.utils import get_params_in_url
# coding=utf-8



def test_copy_http_request():
    req = HttpRequest('http://example.com/', params={'key': 'value'}, meta={'depth': 0})
    copy_req = req.copy()
    assert copy_req.url == req.url
    params = get_params_in_url(copy_req.url)
    assert 'key' in params and params['key'] == ['value']
    assert 'depth' in copy_req.meta and copy_req.meta['depth'] == 0
    req.meta['depth'] = 1
    assert req.meta['depth'] == 1 and copy_req.meta['depth'] == 0


def test_replace_http_request():

# Path: xpaw/http.py
# class HttpRequest:
# class HttpResponse:
#     def __init__(self, url, method="GET", body=None, params=None, headers=None, proxy=None,
#                  timeout=20, verify_ssl=False, allow_redirects=True, auth=None, proxy_auth=None,
#                  priority=None, dont_filter=False, callback=None, errback=None, meta=None,
#                  render=None):
#     def __str__(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):
#     def to_dict(self):
#     def from_dict(cls, d):
#     def __init__(self, url, status, body=None, headers=None,
#                  request=None, encoding=None):
#     def __str__(self):
#     def encoding(self):
#     def encoding(self, value):
#     def text(self):
#     def meta(self):
#     def copy(self):
#     def replace(self, **kwargs):
# 
# Path: xpaw/utils.py
# def get_params_in_url(url):
#     return parse_qs(urlsplit(url).query)


# Path: tests/test_http.py
from xpaw.http import HttpRequest, HttpResponse, HttpHeaders
from xpaw.utils import get_params_in_url

# coding=utf-8



def test_copy_http_request():
    req = HttpRequest('http://example.com/', params={'key': 'value'}, meta={'depth': 0})
    copy_req = req.copy()
    assert copy_req.url == req.url
    params = get_params_in_url(copy_req.url)
    assert 'key' in params and params['key'] == ['value']
    assert 'depth' in copy_req.meta and copy_req.meta['depth'] == 0
    req.meta['depth'] = 1
    assert req.meta['depth'] == 1 and copy_req.meta['depth'] == 0


def test_replace_http_request():

    req = HttpRequest('http://example.com/', 'POST', body=b'body1')