Skip to content

Commit f19f561

Browse files
karol-maciaszekdarrenjennings
authored andcommitted
fix(target/python) query string fix (Kong#138)
* fix(target/python) query string fix * test(target/python) query params support in HAR url * test(target/python) more human-readable fixture
1 parent c8e0b09 commit f19f561

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/targets/python/requests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = function (source, options) {
2626
.blank()
2727

2828
// Construct query string
29-
if (source.queryString.length) {
29+
if (Object.keys(source.queryObj).length) {
3030
var qs = 'querystring = ' + JSON.stringify(source.queryObj)
3131

3232
code.push(qs)

test/targets/python/requests.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
/* global it */
2+
13
'use strict'
24

35
require('should')
46

5-
module.exports = function (snippet, fixtures) {
7+
module.exports = function (HTTPSnippet) {
8+
it('should support query parameters provided in HAR\'s url', function () {
9+
var result = new HTTPSnippet({ 'method': 'GET', 'url': 'http://mockbin.com/har?param=value' }).convert('python', 'requests', {
10+
showBoilerplate: false
11+
})
12+
13+
result.should.be.a.String()
14+
result.should.eql(`import requests
15+
16+
url = "http://mockbin.com/har"
17+
18+
querystring = {"param":"value"}
19+
20+
response = requests.request("GET", url, params=querystring)
21+
22+
print(response.text)`)
23+
})
624
}

0 commit comments

Comments
 (0)