-
Notifications
You must be signed in to change notification settings - Fork 38
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
CKAN test server settings for testthat suite #31
Conversation
…mo url/api key/resource id in the global variables.
…kanr_options with getters and setter
CKAN test server settings for testthat suite
Sorry that I am late. I do not understand why we need two systems to control the behavior of |
But isn't the server @florianm set up a CKAN server like any other? |
@wush978 @sckott not just like any other server - the one and only CKAN providing user-friendly geo-referencing. Jokes aside, my reasoning for using separate test server settings, and also using my own CKAN instance was convenience to develop and test against a latest source install (v2.4a) without writing to a production CKAN. |
@wush978 the majority of tests are still against either http://data.techno-science.ca or http://demo.ckan.org with just some against @florianm server That okay? Good reason to change what we test against? |
Oh, I want to argue that why we should use Or maybe what we need is a handle of connection or an object of configuration. |
@wush978 What do you mean by
And I don't know what these mean
All commits/PR's/new branches are tested against Travis-CI, so we need remote CKAN servers to test against. When I run tests locally, they are run just like they are on Travis, against remote servers. I'm not sure how your desired setup differs. |
@sckott , thanks for your reply. My previous posts are not clear. I want to discuss the need of In #31 (comment), I am wondering the difference of environment set by And @florianm mentioned the convenience of testing, so I want to argue it in #31 (comment). |
In my view, I agree with @sckott on having separate test and production settings, but I like @wush978 's idea of aligning setting/getting them. If I understood both of you correctly, I can satisfy all of our requirements by replacing my #' Configure default CKAN settings
#' @param url A CKAN URL (optional), default: "http://data.techno-science.ca"
#' @param key A CKAN API key (optional)
#' @param test_url (character) A valid CKAN URL for testing purposes
#' @param test_key (character) A valid CKAN API key privileged to create datasets at URL
#' @param test_did (character) A valid CKAN dataset ID, existing at url
#' @param test_rid (character) A valid CKAN resource ID, attached to did
setup_ckanr <- function(
url="http://data.techno-science.ca/", #"my production CKAN URL",
key=NULL, #"my production CKAN API key",
test_url=NULL, #"my test CKAN URL",
test_key=NULL, #"my test CKAN API key",
test_did=NULL, #"my test CKAN existing package ID",
test_rid=NULL #"my test CKAN existing resource ID"){
Sys.setenv(CKANR_DEFAULT_URL = url)
Sys.setenv(CKANR_DEFAULT_KEY = key)
Sys.setenv(CKANR_TEST_URL = test_url)
Sys.setenv(CKANR_TEST_KEY = test_key)
Sys.setenv(CKANR_TEST_DID = test_did)
Sys.setenv(CKANR_TEST_RID = test_rid)
} Re API key: I'd like to use Sys.setenv(CKANR_DEFAULT_KEY) to align environment variable names, and to avoid colliding with the odd user setting their own CKAN API key system-wide (you never know) and adjust Usage: # Unprivileged read-only user could run either of:
setup_ckan("http://data-demo.dpaw.wa.gov.au/")
setup_ckan(url="http://data-demo.dpaw.wa.gov.au/")
set_ckanr_url("http://data-demo.dpaw.wa.gov.au/")
# Privileged CKAN editor/admin user can run either of:
setup_ckan("http://data-demo.dpaw.wa.gov.au/", "some-CKAN-API-key")
setup_ckan(url="http://data-demo.dpaw.wa.gov.au/", key="some-CKAN-API-key")
set_ckanr_url("http://data-demo.dpaw.wa.gov.au/"); set_api_key("some-CKAN-api-key")
# ckanR developer/tester can run either of:
setup_ckan("http://data-demo.dpaw.wa.gov.au/", "some-CKAN-API-key",
"http://test-ckan.dpaw.wa.gov.au/","test-ckan-API-key",
"test-ckan-dataset-id","test-ckan-resource-id")
setup_ckan(url="http://data-demo.dpaw.wa.gov.au/", key="some-CKAN-API-key",
test_url="http://test-ckan.dpaw.wa.gov.au/",test_key="test-ckan-API-key",
test_did="test-ckan-dataset-id",test_rid="test-ckan-resource-id")
set_ckanr_url("http://data-demo.dpaw.wa.gov.au/"); set_api_key("some-CKAN-api-key")
set_test_env(url="http://test-ckan.dpaw.wa.gov.au/", key="test-ckan-API-key",
did="test-ckan-dataset-id", rid="test-ckan-resource-id")
# this would work, but have no effect:
setup_ckan()
# setup_ckan should really message the user about what has (and hasn't) been changed. In all cases, If that's a good idea, the implications would be:
Also I just noticed:
@wush978 thanks for the inspiration! Does my suggestion for |
got excited, made #37 |
I think some helper functions for convenience are great, but they should stand on setup functions for normal users such as
IMO, there are two reasons to use normal setup function such as
Well, I just suggest this because you have written some scripts already. But if we could not resolve some issues related to two setup systems such as api key, maybe we could switch back to this approach. |
I guess the question is: Do users of this package need access to setting their own URL/key/did/etc. for testing? If not, then maybe we only give users ability to set
and that's it. So then we could use an internal function that's not exported to modify any settings for our unit tests - I don't think users need to change testing settings, since if test work against CKAN server X they should work for CKAN server Y, right (assuming they're running the same version of CKAN)? |
@sckott IMHO testers should be able to change their test settings. My thoughts / arguments pro #37 (which I only wrote to clarify my own thoughts and provide a tangible subject for discussion) :
My spin on ckanr's user base: If we were to go down the lines of #37 I'd suggest we're only a short paragraph in the vignette (with a complete contributing and testing workflow) away from making testing for newcomers to R package development like me easy and fun. |
@sckott I agree with you. @florianm We could fulfill your idea and keep things simple at the same time. What you need is some functions for switching url, api key and other configurations. Having such kind of functions is good, but these functions should call IMO, the requirement of |
@wush978 I don't fully understand why we need to detour through Assuming for argument's sake we'd keep setup_ckanr, we could and should That leaves us with one simple setter for all settings and individual Edit: added to #37, see my comments there! Look especially at examples and tests to judge whether settings are handled simpler and more consistent. @wush978 thanks for focusing my thinking and helping to bring consistency into my contributions! On 21/05/2015 8:12 pm, "Wush Wu" notifications@github.com wrote:
|
Including branch 11-resource-update, this branch tries to set CKAN test server settings (url, key, dataset id, resource id) and (not quite succeeds to) use them in tests, currently in test-resource_update and test-ds_dataset_create. I'd be grateful for feedback on how to make testthat pull those settings from ckanr_options or options. Or should we pollute Sys.env with these settings?
This PR is for discussion only, as it contains branch 11-resource-update! This PR addresses #30