import netlib.tutils
from libmproxy import flow_export
from . import tutils

req_get = netlib.tutils.treq(
    method='GET',
    headers=None,
    content=None,
)

req_post = netlib.tutils.treq(
    method='POST',
    headers=None,
)


def test_request_simple():
    flow = tutils.tflow(req=req_get)
    assert flow_export.curl_command(flow)

    flow = tutils.tflow(req=req_post)
    assert flow_export.curl_command(flow)

import netlib.tutils
from libmproxy import flow_export
from . import tutils

req_get = netlib.tutils.treq(
    method='GET',
    content=None,
)

req_post = netlib.tutils.treq(
    method='POST',
    headers=None,
)

req_patch = netlib.tutils.treq(
    method='PATCH',
    path=b"/path?query=param",
)


def test_curl_command():
    flow = tutils.tflow(req=req_get)
    result = """curl -H 'header:qvalue' 'http://address/path'"""
    assert flow_export.curl_command(flow) == result

    flow = tutils.tflow(req=req_post)
    result = """curl -X POST 'http://address/path' --data-binary 'content'"""
    assert flow_export.curl_command(flow) == result

    flow = tutils.tflow(req=req_patch)
    result = """curl -H 'header:qvalue' -X PATCH 'http://address/path?query=param' --data-binary 'content'"""
    assert flow_export.curl_command(flow) == result


Test exact return value of flow_export.curl_command
Test exact return value of flow_export.curl_command

  import netlib.tutils
  from libmproxy import flow_export
  from . import tutils
  
  req_get = netlib.tutils.treq(
      method='GET',
-     headers=None,
      content=None,
  )
  
  req_post = netlib.tutils.treq(
      method='POST',
      headers=None,
  )
  
+ req_patch = netlib.tutils.treq(
+     method='PATCH',
+     path=b"/path?query=param",
+ )
  
- def test_request_simple():
+ 
+ def test_curl_command():
      flow = tutils.tflow(req=req_get)
+     result = """curl -H 'header:qvalue' 'http://address/path'"""
-     assert flow_export.curl_command(flow)
+     assert flow_export.curl_command(flow) == result
  
      flow = tutils.tflow(req=req_post)
+     result = """curl -X POST 'http://address/path' --data-binary 'content'"""
-     assert flow_export.curl_command(flow)
+     assert flow_export.curl_command(flow) == result
  
+     flow = tutils.tflow(req=req_patch)
+     result = """curl -H 'header:qvalue' -X PATCH 'http://address/path?query=param' --data-binary 'content'"""
+     assert flow_export.curl_command(flow) == result
+ 
+ 
Test exact return value of flow_export.curl_command
## Code Before:
import netlib.tutils
from libmproxy import flow_export
from . import tutils

req_get = netlib.tutils.treq(
    method='GET',
    headers=None,
    content=None,
)

req_post = netlib.tutils.treq(
    method='POST',
    headers=None,
)


def test_request_simple():
    flow = tutils.tflow(req=req_get)
    assert flow_export.curl_command(flow)

    flow = tutils.tflow(req=req_post)
    assert flow_export.curl_command(flow)

## Instruction:
Test exact return value of flow_export.curl_command
## Code After:
import netlib.tutils
from libmproxy import flow_export
from . import tutils

req_get = netlib.tutils.treq(
    method='GET',
    content=None,
)

req_post = netlib.tutils.treq(
    method='POST',
    headers=None,
)

req_patch = netlib.tutils.treq(
    method='PATCH',
    path=b"/path?query=param",
)


def test_curl_command():
    flow = tutils.tflow(req=req_get)
    result = """curl -H 'header:qvalue' 'http://address/path'"""
    assert flow_export.curl_command(flow) == result

    flow = tutils.tflow(req=req_post)
    result = """curl -X POST 'http://address/path' --data-binary 'content'"""
    assert flow_export.curl_command(flow) == result

    flow = tutils.tflow(req=req_patch)
    result = """curl -H 'header:qvalue' -X PATCH 'http://address/path?query=param' --data-binary 'content'"""
    assert flow_export.curl_command(flow) == result

