add logic for persisting pixiv sessions in tests

This commit is contained in:
Albert Yi
2018-05-10 13:58:42 -07:00
parent 76eeafca2c
commit 6839249e9d
5 changed files with 41 additions and 1 deletions

View File

@@ -154,6 +154,9 @@ class PixivApiClient
else
raise Error.new("Pixiv API call failed (status=#{resp.code} body=#{body})")
end
rescue Net::OpenTimeout
sleep(5)
retry
rescue JSON::ParserError
raise Error.new("Pixiv API call failed (status=#{resp.code} body=#{body})")
end
@@ -173,7 +176,7 @@ class PixivApiClient
}
url = "https://oauth.secure.pixiv.net/auth/token"
resp = HTTParty.post(url, Danbooru.config.httparty_options.deep_merge(timeout: 20, body: params, headers: headers))
resp = HTTParty.post(url, Danbooru.config.httparty_options.deep_merge(body: params, headers: headers))
body = resp.body.force_encoding("utf-8")
if resp.success?