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

Commit

Permalink
added conditional sandbox test suite (closes #100)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Feb 21, 2016
1 parent aace462 commit 9ec0227
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ env:
global:
- secure: Kg4ZQvRHolP5lKs8HTwU7Tq8GoDFsL67HWwcpRSeIEJRxPiEo7Fz2OwsdRfXcG69Zl2PP6089HwAylrxoe4YiZUIFJPER4gJnkRz93Iq/K4QinBmtMzIDwIOds4y0pq0VFZJIQMNrgMtaIZFZyylYxfZbrSK25ynCGG/oFvaFGU=
- secure: Lgb6SLbbSWBaHiBHsdrRbq3MgvMbu/5Iv1VCjDqLu4vw9wzBmFHryYy6kBCHwTWjopYu7h8lDrb2U45SZxWgHX9cL0ubn3z6HW5UzWIRcpRDQ1H5oEeKzlCrEiG9CxsELXame2yq5+46GLpLrUZyEA4aLXvXlhKx9ds2uxxpAlA=
- secure: h6fCtCVNtRRBs+dFspYg//M6q/bQT/8No/TkuXutqmJk0R84Zhuf/FGfCr8lrLFVqUmAWQqyEcJJcoC5lmIY1R0+WI8p7gSkM7Gkj8YwtLHH77s6h1nKcyxmAs/EBQw71El5NdPmWxXIDcGvfDytk5ms5AaRzXhIJAz82Bm9RWc=
- secure: Lryi4zAqD+hB7hyaWsSx4SUlXOrRXDtteELBkREyku1FSEDPPendGg7Z0Sdaiy22nKEsfL4MUgIrVh1VqAtvqznyWGTc2NDGZArOVFhMS5ErA9MG6kN1g2jQCezuZN9VzKIIiftawjM+VKMIfyqdf4PAvVL4KdH6p+6p1Hr3wpA=
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: MTurkR
Version: 0.6.26
Version: 0.6.27
Date: 2016-02-21
Title: R Client for the MTurk Requester API
Authors@R: c(person("Thomas J.", "Leeper", role = c("aut", "cre"),
Expand All @@ -9,6 +9,7 @@ Authors@R: c(person("Thomas J.", "Leeper", role = c("aut", "cre"),
person("Jonathan", "Chang", role = "ctb"))
Maintainer: Thomas J. Leeper <thosjleeper@gmail.com>
Imports: utils, stats, curl, digest, base64enc, XML
Suggests: testthat
Description: Provides programmatic access to the Amazon Mechanical Turk (MTurk) Requester API.
License: GPL-2
URL: https://github.com/leeper/MTurkR
Expand Down
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## SIGNIFICANT USER-VISIBLE CHANGES ##

* `GenerateExternalQuestion()` now sets a default value of `frame.height = 400`.
* `GenerateExternalQuestion` now sets a default value of `frame.height = 400`.
* The AWS Access Key ID used for requests is now redacted from the error message printing when an API request fails to reduce the risk of accidentally disclosing the credential. (#105)
* AWS removed the Categorization and Photo Moderation QualificationTypes on December 18th, 2015. Use of these QualificationTypeIds will trigger warnings in some cases and the "generic" Masters QualificationTypeId will be substituted automatically. Users should not need to update any code, though they may be receive warnings. These have also been removed from `ListQualificationTypes()`. (#104)
* The use of `credentials()`, and `options("MTurkR.keypair")` are completely deprecated. A warning will now be issued if trying to supply credentials in this way. AWS credentials should be specified in environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. Messages are triggered on package load if environment variables are not set. (#102)
Expand All @@ -20,6 +20,7 @@

## DOCUMENTATION ##

* A small test suite has been added to help ensure correct package functionality. It is only executed in the sandbox in the presence of valid AWS credentials. (#100)
* The package now includes pages describing common use cases for MTurk (surveys, categorization, sentiment analysis, and webscraping). (#98)
* Descriptions of global package options have been added to MTurkR-package.Rd. (#103)
* The package now includes additional HTMLQuestion templates including examples for image categorization and sentiment rating. (#94)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ If you experience problems using MTurkR, you can:
[![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)
[![Travis-CI Build Status](https://travis-ci.org/leeper/MTurkR.png?branch=master)](https://travis-ci.org/leeper/MTurkR)
[![Build status](https://ci.appveyor.com/api/projects/status/432l8e6qycnfi8ci?svg=true)](https://ci.appveyor.com/project/leeper/mturkr)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/432l8e6qycnfi8ci?svg=true)](https://ci.appveyor.com/project/leeper/mturkr)
[![codecov.io](http://codecov.io/github/leeper/MTurkR/coverage.svg?branch=master)](http://codecov.io/github/leeper/MTurkR?branch=master)

To install the latest version from CRAN, simply use:

Expand Down
2 changes: 1 addition & 1 deletion man/UpdateQualificationType.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ UpdateQualificationType(qual1$QualificationTypeId,
DisposeQualificationType(qual1$QualificationTypeId)
}
}
\keyword{Qualifications}
\keyword{Qualifications}
9 changes: 9 additions & 0 deletions tests/test-all.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library("testthat")
k1 <- Sys.getenv("AWS_ACCESS_KEY_ID")
k2 <- Sys.getenv("AWS_SECRET_ACCESS_KEY")
if ((k1 != "") && (k2 != "")) {
library("MTurkR")
options("MTurkR.sandbox" = TRUE)
options('MTurkR.log' = FALSE)
test_check("MTurkR")
}
84 changes: 84 additions & 0 deletions tests/testthat/tests.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
context("Sandbox Tests")

test_that("Account Balance Check", {
expect_true(as.numeric(AccountBalance()$balance) == 10000)
})

r <- RegisterHITType(title = "Example HITType",
description = "empty",
reward = "0.01",
duration = seconds(seconds = 30),
keywords = "empty",
sandbox = TRUE)
test_that("RegisterHITType", {
expect_true(nrow(r) == 1)
})

h <- CreateHIT(hit.type = r$HITTypeId,
question = GenerateExternalQuestion("https://www.example.com"),
assignments = 1,
expiration = seconds(seconds = 30),
sandbox = TRUE)
test_that("CreateHIT", {
expect_true(nrow(h) == 1)
expect_true(as.character(r$HITTypeId[1]) == as.character(h$HITTypeId[1]))
})

test_that("ExtendHIT (assignments)", {
e1 <- ExtendHIT(hit = h$HITId, add.assignments = 1, sandbox = TRUE)
expect_true(nrow(e1) == 1)
})

test_that("ExtendHIT (seconds)", {
e1 <- ExtendHIT(hit = h$HITId, add.seconds = 3600, sandbox = TRUE)
expect_true(nrow(e1) == 1)
})

test_that("ExpireHIT", {
e2 <- ExpireHIT(hit = h$HITId, sandbox = TRUE)
expect_true(nrow(e2) == 1)
})

test_that("ChangeHITType", {
r2 <- RegisterHITType(title = "Example HITType 2",
description = "empty",
reward = "0.01",
duration = seconds(seconds = 30),
keywords = "empty",
sandbox = TRUE)
ch <- ChangeHITType(hit = h$HITId, new.hit.type = r2$HITTypeId)
expect_true(nrow(ch) == 1)
})

test_that("GetAssignments", {
a <- GetAssignments(hit = h$HITId, sandbox = TRUE)
expect_true(nrow(a) == 0)
})

test_that("DisposeHIT", {
d <- DisposeHIT(hit = h$HITId, sandbox = TRUE)
expect_true(nrow(d) == 1)
})

q1 <- CreateQualificationType(name = "Example Qualification for Tests",
description = "empty",
status = "Active",
keywords = "none",
sandbox = TRUE)
test_that("CreateQualificationType", {
expect_true(nrow(q1) == 1)
})

test_that("UpdateQualificationType", {
u <- UpdateQualificationType(q1$QualificationTypeId,
description = "new",
sandbox = TRUE)
expect_true(nrow(u) == 1)
g <- GetQualificationType(q1$QualificationTypeId, sandbox = TRUE)
expect_true(g$Description[1] == "new")
})

test_that("DisposeQualificationType", {
dis <- DisposeQualificationType(q1$QualificationTypeId, sandbox = TRUE)
expect_true(nrow(dis) == 1)
})

0 comments on commit 9ec0227

Please sign in to comment.