Skip to content

Commit 959cb1d

Browse files
committed
add some basic tests for new cred/config dev
1 parent 92981d9 commit 959cb1d

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
include("tests.jl")
1+
include("tests.jl")
2+
include("test_utils.jl")

test/test_utils.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,18 @@ using Plotly
22
using JSON
33
using Base.Test
44

5+
#test signin only one endpoint specified
6+
@test_throws ErrorException Plotly.signin("fake_username", "fake_api_key", {"plotly_domain"=>"test"})
7+
8+
#test signin and get_credentials
9+
Plotly.signin("test_username", "test_api_key")
10+
creds = Plotly.get_credentials()
11+
@test creds.username == "test_username"
12+
@test creds.api_key == "test_api_key"
13+
14+
#test signin + endpoints and get_config
15+
endpoints = {"plotly_domain"=>"my_plotly_domain", "plotly_api_domain"=>"my_plotly_api_domain"}
16+
Plotly.signin("test_username", "test_api_key", endpoints)
17+
config = Plotly.get_config()
18+
@test config.plotly_domain == "my_plotly_domain"
19+
@test config.plotly_api_domain== "my_plotly_api_domain"

test/tests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,17 @@ figure = Plotly.getFile("5", "chris")
3737

3838
response = Plotly.plot(figure["data"], ["layout"=> figure["layout"], "filename" => "test_get_figure_plot"])
3939
@test response["error"] == ""
40+
41+
#test get_plot_endpoint
42+
endpoints = {"plotly_domain"=>"my_plotly_domain", "plotly_api_domain"=>"my_plotly_api_domain"}
43+
Plotly.signin("test_username", "test_api_key", endpoints)
44+
plot_endpoint = Plotly.get_plot_endpoint()
45+
@test plot_endpoint == "my_plotly_domain/clientresp"
46+
47+
#test get_content_endpoint
48+
endpoints = {"plotly_domain"=>"my_plotly_domain", "plotly_api_domain"=>"my_plotly_api_domain"}
49+
Plotly.signin("test_username", "test_api_key", endpoints)
50+
fid = "123_fake"
51+
owner = "test_owner"
52+
content_endpoint = Plotly.get_content_endpoint(fid, owner)
53+
@test content_endpoint == "my_plotly_api_domain/files/test_owner:123_fake/content"

0 commit comments

Comments
 (0)