Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Commit

Permalink
fix tests for 0.8.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Jan 22, 2017
1 parent 7abcd90 commit 090aad5
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 79 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: MTurkR
Version: 0.7.11
Date: 2016-07-26
Version: 0.8.0
Date: 2017-01-22
Title: R Client for the MTurk Requester API
Authors@R: c(person("Thomas J.", "Leeper", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down
96 changes: 49 additions & 47 deletions NEWS → NEWS.md

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions R/GetStatistic.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ statistic <-
function (statistic, period = "LifeToDate", count = NULL, response.group = NULL,
verbose = getOption('MTurkR.verbose', TRUE), ...) {
operation <- "GetRequesterStatistic"
value.long <- c("NumberAssignmentsAvailable", "NumberAssignmentsAccepted",
"NumberAssignmentsPending", "NumberAssignmentsApproved",
"NumberAssignmentsRejected", "NumberAssignmentsReturned",
"NumberAssignmentsAbandoned", "NumberHITsCreated", "NumberHITsCompleted",
value.long <- c("NumberAssignmentsPending", "NumberAssignmentsApproved",
"NumberAssignmentsRejected", "NumberAssignmentsAbandoned",
"NumberHITsCreated", "NumberHITsCompleted",
"NumberHITsAssignable", "NumberHITsReviewable")
value.double <- c("PercentAssignmentsApproved", "PercentAssignmentsRejected",
"TotalRewardPayout", "AverageRewardAmount", "TotalRewardFeePayout",
"TotalFeePayout", "TotalRewardAndFeePayout", "TotalBonusPayout",
"TotalBonusFeePayout", "EstimatedRewardLiability", "EstimatedFeeLiability",
"TotalBonusPayout", "TotalBonusFeePayout",
"EstimatedRewardLiability", "EstimatedFeeLiability",
"EstimatedTotalLiability")
if (!statistic %in% value.long & !statistic %in% value.double) {
stop("Statistic not valid")
Expand Down
5 changes: 0 additions & 5 deletions R/ListStatistics.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
ListStatistics <-
function (stat = NULL, value.type = NULL, type = NULL) {
stats <- setNames(as.data.frame(rbind(
c("NumberAssignmentsAvailable", "Long", "GetRequesterStatistic"),
c("NumberAssignmentsAccepted", "Long", "GetRequesterStatistic"),
c("NumberAssignmentsPending", "Long", "GetRequesterStatistic"),
c("NumberAssignmentsApproved", "Long", "GetRequesterStatistic"),
c("NumberAssignmentsRejected", "Long", "GetRequesterStatistic"),
c("NumberAssignmentsReturned", "Long", "GetRequesterStatistic"),
c("NumberAssignmentsAbandoned", "Long", "GetRequesterStatistic"),
c("NumberHITsCreated", "Long", "GetRequesterStatistic"),
c("NumberHITsCompleted", "Long", "GetRequesterStatistic"),
Expand All @@ -17,8 +14,6 @@ function (stat = NULL, value.type = NULL, type = NULL) {
c("TotalRewardPayout", "Double", "GetRequesterStatistic"),
c("AverageRewardAmount", "Double", "GetRequesterStatistic"),
c("TotalRewardFeePayout", "Double", "GetRequesterStatistic"),
c("TotalFeePayout", "Double", "GetRequesterStatistic"),
c("TotalRewardAndFeePayout", "Double", "GetRequesterStatistic"),
c("TotalBonusPayout", "Double", "GetRequesterStatistic"),
c("TotalBonusFeePayout", "Double", "GetRequesterStatistic"),
c("EstimatedRewardLiability", "Double", "GetRequesterStatistic"),
Expand Down
26 changes: 15 additions & 11 deletions R/RequesterReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ function (period = "LifeToDate", verbose = getOption('MTurkR.verbose', TRUE), ..
if (!period %in% c("OneDay", "SevenDays", "ThirtyDays", "LifeToDate")) {
stop("Period not valid")
}
statistics <- c("NumberAssignmentsAvailable", "NumberAssignmentsAccepted",
"NumberAssignmentsPending", "NumberAssignmentsApproved",
"NumberAssignmentsRejected", "NumberAssignmentsReturned",
statistics <- c(
"NumberAssignmentsPending", "NumberAssignmentsApproved", "NumberAssignmentsRejected",
"NumberAssignmentsAbandoned", "NumberHITsCreated", "NumberHITsCompleted",
"NumberHITsAssignable", "NumberHITsReviewable", "PercentAssignmentsApproved",
"PercentAssignmentsRejected", "TotalRewardPayout", "AverageRewardAmount",
"TotalRewardFeePayout", "TotalFeePayout", "TotalRewardAndFeePayout",
"TotalBonusPayout", "TotalBonusFeePayout", "EstimatedRewardLiability",
"TotalRewardFeePayout", "TotalBonusPayout",
"TotalBonusFeePayout", "EstimatedRewardLiability",
"EstimatedFeeLiability", "EstimatedTotalLiability")
z <- emptydf(length(statistics), 2, c("Statistic", "Value"))
z[, 1] <- statistics
for (i in 1:20) {
z[i, 2] <- GetStatistic(statistics[i], period = period, ...)
z[["Statistic"]] <- statistics
only_ltd <- c("NumberHITsAssignable", "EstimatedRewardLiability", "EstimatedFeeLiability", "EstimatedTotalLiability")
for (i in seq_along(statistics)) {
if (statistics[i] %in% only_ltd) {
if (statistics[i] == "NumberHITsAssignable" && period != "LifeToDate") {
message("'NumberHITsAssignable' is being retrieved for period 'LifeToDate'")
}
z[i, 2] <- GetStatistic(statistics[i], period = "LifeToDate", verbose = verbose, ...)[["Value"]]
} else {
z[i, 2] <- GetStatistic(statistics[i], period = period, verbose = verbose, ...)[["Value"]]
}
}
for (i in 21:23) {
z[i, 2] <- GetStatistic(statistics[i], period = "LifeToDate", ...)
}
return(z)
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ If you experience problems using MTurkR, you can:

## Installation ##

[![CRAN Version](http://www.r-pkg.org/badges/version/MTurkR)](http://cran.r-project.org/package=MTurkR)
![Downloads](http://cranlogs.r-pkg.org/badges/MTurkR)
[![CRAN Version](https://www.r-pkg.org/badges/version/MTurkR)](https://cran.r-project.org/package=MTurkR)
![Downloads](https://cranlogs.r-pkg.org/badges/MTurkR)
[![Travis-CI Build Status](https://travis-ci.org/cloudyr/MTurkR.png?branch=master)](https://travis-ci.org/cloudyr/MTurkR)
[![codecov.io](http://codecov.io/github/cloudyr/MTurkR/coverage.svg?branch=master)](http://codecov.io/github/cloudyr/MTurkR?branch=master)
[![codecov.io](https://codecov.io/github/cloudyr/MTurkR/coverage.svg?branch=master)](https://codecov.io/github/cloudyr/MTurkR?branch=master)

To install the latest version from CRAN, simply use:

Expand All @@ -43,7 +43,7 @@ To install the latest development version of **MTurkR** from GitHub:
install.packages("MTurkR", repos = c(getOption("repos"), "http://cloudyr.github.io/drat"))

# latest (unstable) version from GitHub
if(!require("ghit")){
if (!require("ghit")) {
install.packages("ghit")
}
ghit::install_github("cloudyr/MTurkR")
Expand Down
2 changes: 1 addition & 1 deletion man/GetStatistic.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Retrieve a specific requester or worker statistic. The list of available statist
}
\examples{
\dontrun{
GetStatistic("NumberHITsSubmitted","OneDay")
GetStatistic("NumberHITsCompleted","OneDay")
RequesterReport("ThirtyDays")
GetWorkerStatistic("A1RO9UJNWXMU65","PercentHITsApproved","LifeToDate")
WorkerReport("A1RO9UJNWXMU65","SevenDays")
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ test_that("Account Balance Check", {
Sys.sleep(1)

test_that("RequesterReport", {
expect_true(is.data.frame(RequesterReport()))
expect_true(is.data.frame(WorkerReport("A1RO9UJNWXMU65", period = "OneDay", sandbox = TRUE)))
expect_true(is.data.frame(RequesterReport(sandbox = TRUE)))
expect_true(is.data.frame(RequesterReport(period = "OneDay", sandbox = TRUE)))
})

Sys.sleep(1)

test_that("RequesterReport", {
test_that("WorkerReport", {
expect_true(is.data.frame(WorkerReport("A1RO9UJNWXMU65", sandbox = TRUE)))
expect_true(is.data.frame(WorkerReport("A1RO9UJNWXMU65", period = "OneDay", sandbox = TRUE)))
})
Expand Down

0 comments on commit 090aad5

Please sign in to comment.