]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Added migration for Request headers to be a dict of lists
authorMax Shytikov <mshytikov@gmail.com>
Tue, 29 Apr 2014 23:43:47 +0000 (01:43 +0200)
committerMax Shytikov <mshytikov@gmail.com>
Fri, 2 May 2014 05:32:17 +0000 (07:32 +0200)
vcr/migration.py

index 947e4f9d2d242066e0a6e324987cdbce4654b0c6..a06e9ad5b3f2e515b9d26b836e43629cfc0dc509 100644 (file)
@@ -47,6 +47,10 @@ def migrate_json(in_fp, out_fp):
         req = item['request']
         uri = dict((k, req.pop(k)) for k in PARTS)
         req['uri'] = build_uri(**uri)
+        # convert headers to dict of lists
+        headers = req['headers']
+        for k in headers:
+            headers[k] = [headers[k]]
     json.dump(data, out_fp, indent=4)
 
 
@@ -87,6 +91,12 @@ def migrate_yml(in_fp, out_fp):
                 req.__dict__['path'],
             )
 
+            # convert headers to dict of lists
+            headers = req.headers
+            req.headers = {}
+            for key, value in headers:
+                req.add_header(key, value)
+
     data = yamlserializer.serialize({
         "requests": requests,
         "responses": responses,