2016-08-03 07:35:58 +03:00
|
|
|
import os
|
2016-08-03 18:38:10 +03:00
|
|
|
import StringIO
|
|
|
|
import xml.etree.ElementTree as ET
|
2016-08-03 07:35:58 +03:00
|
|
|
|
|
|
|
from vcr import VCR
|
|
|
|
|
2016-08-03 18:38:10 +03:00
|
|
|
|
|
|
|
def scrub_auth(request):
|
|
|
|
xml = StringIO.StringIO(request.body)
|
|
|
|
tree = ET.parse(xml)
|
|
|
|
root = tree.getroot()
|
2016-08-03 18:45:57 +03:00
|
|
|
auth_param = root.findall('./params/param/value/string')[0]
|
2016-08-03 18:38:10 +03:00
|
|
|
auth_param.text = 'someuser:sometoken'
|
|
|
|
scrubbed = StringIO.StringIO()
|
|
|
|
tree.write(scrubbed)
|
|
|
|
scrubbed.seek(0)
|
|
|
|
request.body = scrubbed.read()
|
|
|
|
return request
|
|
|
|
|
|
|
|
|
2016-08-03 07:35:58 +03:00
|
|
|
vcr = VCR(
|
|
|
|
serializer='yaml',
|
|
|
|
cassette_library_dir=os.path.join(
|
|
|
|
os.path.dirname(os.path.realpath(__file__)), 'fixtures/oneclient'
|
|
|
|
),
|
|
|
|
record_mode='once',
|
2016-08-03 18:33:36 +03:00
|
|
|
decode_compressed_response=True,
|
2016-08-03 18:31:40 +03:00
|
|
|
path_transformer=VCR.ensure_suffix('.yaml'),
|
2016-08-03 18:38:10 +03:00
|
|
|
before_record=scrub_auth,
|
2016-08-03 07:35:58 +03:00
|
|
|
)
|