Skip to content

Fix response filepath when contains directory #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: plotly
Type: Package
Title: Interactive, publication-quality graphs online.
Version: 0.5.17
Version: 0.5.18
Authors@R: c(person("Chris", "Parmer", role = c("aut", "cre"),
email = "[email protected]"),
person("Scott", "Chamberlain", role = "aut",
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.5.18 -- 22 January 2015.

Return proper filepath when filename contains directories.

0.5.17 -- 30 December 2014.

Support date-time binning in histograms.
Expand Down
2 changes: 1 addition & 1 deletion R/plotly-package.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' \itemize{
#' \item Package: plotly
#' \item Type: Package
#' \item Version: 0.5.17
#' \item Version: 0.5.18
#' \item Date: 2014-03-07
#' \item License: MIT
#' }
Expand Down
6 changes: 3 additions & 3 deletions R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ For more help, see https://plot.ly/R or contact <[email protected]>.")

# public attributes/methods that the user has access to
pub <- list(username=username, key=key, filename="from api", fileopt=NULL,
version="0.5.17")
version="0.5.18")
priv <- list()

pub$makecall <- function(args, kwargs, origin) {
Expand All @@ -105,8 +105,8 @@ For more help, see https://plot.ly/R or contact <[email protected]>.")
}

resp <- fromJSON(respst, simplify = FALSE)
if (!is.null(resp$filename))
pub$filename <- resp$filename
if (!is.null(kwargs$filename))
resp$filename <- kwargs$filename
if (!is.null(resp$error))
cat(resp$err)
if (!is.null(resp$warning))
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-plotly-filename.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
context("Filename")

test_that("filepath with directories is returned as passed", {
x <- c(-1.50548425849621, 0.023267831354017, -1.38460390550496,
-0.805552814226363, 1.59651736643461, 0.936302685370894,
0.512729504994891, -0.24492573745161, -0.465348603632604,
0.173523456651353, 0.389491211182137, -0.275308705542518,
-0.132866228059449, -0.336255877656944, 0.916535489109209,
-0.936870130264329, 0.363137478307925, -1.26433467241078,
-0.388804188531171, 0.785842426281935)
data = list(x=x, type="histogramx")
l <- list(autosize=FALSE, width=600, height=400, showlegend=FALSE)

py <- plotly("get_test_user_2", "0f9es4r6tm")
response <- py$plotly(data, kwargs=list(layout=l, filename="directory/hist",
fileopt="overwrite"))

expect_identical(response$filename, "directory/hist")

})