forked from dirk/HTTP.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from loladiro/tests
basic tests, fixes dirk#7
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
language: cpp | ||
compiler: | ||
- gcc | ||
notifications: | ||
email: false | ||
before_install: | ||
- sudo add-apt-repository ppa:staticfloat/julia-deps -y | ||
- sudo add-apt-repository ppa:staticfloat/julianightlies -y | ||
- sudo apt-get update -qq -y | ||
- sudo apt-get install git libpcre3-dev julia -y | ||
- git config --global user.name "Travis User" | ||
- git config --global user.email "[email protected]" | ||
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi | ||
script: | ||
- julia -e 'versioninfo(); Pkg.init(); Pkg.clone(pwd())' | ||
- julia ./test/runtests.jl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
using Requests | ||
using JSON | ||
using Base.Test | ||
|
||
|
||
# simple calls, no headers, data or query params ------- | ||
|
||
@test get("http://httpbin.org/get").status === 200 | ||
@test post("http://httpbin.org/post").status === 200 | ||
@test put("http://httpbin.org/put").status === 200 | ||
@test delete("http://httpbin.org/delete").status === 200 | ||
@test options("http://httpbin.org/get").status === 200 | ||
|
||
|
||
# check query params ------- | ||
|
||
data = JSON.parse(get("http://httpbin.org/get"; query = {"key1" => "value1"}).data) | ||
@test data["args"]["key1"] == "value1" | ||
|
||
data = JSON.parse(post("http://httpbin.org/post"; query = {"key1" => "value1", | ||
"key2" => "value2" }).data) | ||
@test data["args"]["key1"] == "value1" | ||
@test data["args"]["key2"] == "value2" | ||
|
||
data = JSON.parse(put("http://httpbin.org/put"; query = {"key1" => "value1", | ||
"key2" => "value2", | ||
"key3" => 3 }).data) | ||
@test data["args"]["key1"] == "value1" | ||
@test data["args"]["key2"] == "value2" | ||
@test data["args"]["key3"] == "3" | ||
|
||
data = JSON.parse(delete("http://httpbin.org/delete"; query = {"key1" => "value1", | ||
"key4" => 4.01 }).data) | ||
@test data["args"]["key1"] == "value1" | ||
@test data["args"]["key4"] == "4.01" | ||
|
||
data = JSON.parse(options("http://httpbin.org/get"; query = {"key1" => "value1", | ||
"key2" => "value2", | ||
"key3" => 3, | ||
"key4" => 4.01 }).data) | ||
@test data == nothing | ||
|
||
|
||
#check data ------- | ||
|
||
data = JSON.parse(post("http://httpbin.org/post"; data = {"key1" => "value1", | ||
"key2" => "value2" }).data) | ||
@test data["json"]["key1"] == "value1" | ||
@test data["json"]["key2"] == "value2" | ||
|
||
data = JSON.parse(put("http://httpbin.org/put"; data = {"key1" => "value1", | ||
"key2" => "value2", | ||
"key3" => 3 }).data) | ||
@test data["json"]["key1"] == "value1" | ||
@test data["json"]["key2"] == "value2" | ||
@test data["json"]["key3"] == 3 | ||
|
||
data = JSON.parse(delete("http://httpbin.org/delete"; data = {"key1" => "value1", | ||
"key4" => 4.01 }).data) | ||
@test data["json"]["key1"] == "value1" | ||
@test data["json"]["key4"] == 4.01 | ||
|
||
|
||
|