Skip to content

Commit 4d99abb

Browse files
committed
test getfigure
1 parent eb4bb1f commit 4d99abb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
context("get_figure")
2+
3+
test_that("requests made by a user who doesn't exist error a 404", {
4+
py <- plotly("user_does_not_exist", "api_key_shouldnt_matter")
5+
expect_error({
6+
py$get_figure("get_test_user", 0);
7+
}, "404")
8+
});
9+
10+
test_that("requests made to retrieve a file that doesn't error return a 404", {
11+
py <- plotly("get_test_user", "vgs6e0cnoi")
12+
expect_error({
13+
py$get_figure("get_test_user", 1000);
14+
}, "404")
15+
});
16+
17+
test_that("requests made with the wrong API key error a 401", {
18+
py <- plotly("get_test_user", "some_invalid_api_key")
19+
expect_error({
20+
py$get_figure("get_test_user", 1);
21+
}, "401")
22+
});
23+
24+
test_that("requests made to retrieve some elses private file errors a 403", {
25+
py <- plotly("get_test_user_2", "0f9es4r6tm")
26+
expect_error({
27+
py$get_figure("get_test_user", 1);
28+
}, "403")
29+
});
30+
31+
test_that("requests made to retrieve some elses private file errors a 403", {
32+
py <- plotly("get_test_user_2", "0f9es4r6tm")
33+
expect_error({
34+
py$get_figure("get_test_user", 1);
35+
}, "403")
36+
});
37+
38+
test_that("retrieving a public figure ... works.", {
39+
py <- plotly("get_test_user_2", "0f9es4r6tm")
40+
figure = py$get_figure("get_test_user", 0);
41+
42+
expect_equivalent(figure$data[[1]]$x, list("1", "2", "3"))
43+
44+
});

0 commit comments

Comments
 (0)