1
- r_version <- paste(R.version $ major , R.version $ minor , sep = " ." )
2
- r_release <- rversions :: r_release()$ version
3
- is_release <- isTRUE(r_release == r_version )
4
- is_win <- .Platform $ OS.type == " windows"
5
-
6
- skip_cloud_tests <- function () {
7
- skip_on_cran()
8
- if (is.na(Sys.getenv(" plotly_username" , NA ))) {
9
- skip(" Cloud testing requires a plotly account (plotly_username)" )
10
- }
11
- if (is.na(Sys.getenv(" plotly_api_key" , NA ))) {
12
- skip(" Cloud testing requires a plotly account (plotly_api_key)" )
13
- }
14
- if (! is_release || ! is_win ) {
15
- skip(" Cloud testing is only run on Windows with the current release of R" )
16
- }
17
- }
18
-
19
-
20
1
test_that(" api() returns endpoints" , {
21
2
skip_cloud_tests()
22
3
@@ -33,8 +14,7 @@ test_that("Can search with white-space", {
33
14
})
34
15
35
16
test_that(" Changing a filename works" , {
36
- skip_on_cran()
37
- skip_if_not_master()
17
+ skip_cloud_tests()
38
18
39
19
id <- plotly ::: new_id()
40
20
f <- api(" files/cpsievert:14680" , " PATCH" , list (filename = id ))
@@ -174,3 +154,58 @@ test_that("filename supports names with paths included ", {
174
154
expect_match(f $ filename , " awesome" )
175
155
expect_true(f $ parented )
176
156
})
157
+
158
+
159
+
160
+
161
+ test_that(" requests made by a user who doesn't exist error a 404" , {
162
+ skip_cloud_tests()
163
+
164
+ expect_error({
165
+ get_figure(" klmadslfjdfljdsf" , 0 )
166
+ }, " .*404.*" )
167
+ })
168
+
169
+ test_that(" requests made to retrieve a figure that doesn't exist returns a 404" , {
170
+ skip_cloud_tests()
171
+
172
+ expect_error({
173
+ get_figure(" get_test_user" , 18324823 )
174
+ }, " .*404.*" )
175
+ })
176
+
177
+ test_that(" requests made to retrieve some elses private file errors" , {
178
+ skip_cloud_tests()
179
+
180
+ expect_error(get_figure(" get_test_user" , 1 ))
181
+ })
182
+
183
+ test_that(" retrieving a public figure ... works." , {
184
+ skip_cloud_tests()
185
+
186
+ fig <- get_figure(" get_test_user" , 0 )
187
+ # get the data behind the hash
188
+ p <- plotly_build(fig )$ x
189
+ expect_equivalent(p $ data [[1 ]]$ x , c(" 1" , " 2" , " 3" ))
190
+ })
191
+
192
+ test_that(" can add traces to a subplot figure" , {
193
+ skip_cloud_tests()
194
+
195
+ fig <- get_figure(' chelsea_lyn' , 6366 )
196
+ p <- add_lines(fig , x = c(1 , 2 , 3 ), y = c(4 , 2 , 4 ))
197
+ expect_equivalent(
198
+ length(plotly_build(fig )$ x $ data ) + 1 ,
199
+ length(plotly_build(p )$ x $ data )
200
+ )
201
+ })
202
+
203
+ test_that(" posting a hidden plot returns a secret key" , {
204
+ skip_cloud_tests()
205
+
206
+ res <- api_create(plot_ly(), sharing = " secret" )
207
+ expect_true(res $ share_key_enabled )
208
+ expect_true(nchar(res $ share_key ) > 1 )
209
+ })
210
+
211
+
0 commit comments