From 2ea52daa8cd1201fe1bf97a351f47225d1feaa1e Mon Sep 17 00:00:00 2001 From: billingtt Date: Wed, 18 Dec 2024 08:39:04 -0500 Subject: [PATCH] Swap examples creds and update tests --- README.Rmd | 10 +-- README.md | 74 ++++------------------- tests/testthat/setup-acled_access.R | 2 +- tests/testthat/test-acled_access.R | 3 +- tests/testthat/test-acled_api.R | 4 +- tests/testthat/test-acled_deletions_api.R | 6 +- vignettes/get_started.Rmd | 2 +- 7 files changed, 23 insertions(+), 78 deletions(-) diff --git a/README.Rmd b/README.Rmd index e7501df..7da9b77 100755 --- a/README.Rmd +++ b/README.Rmd @@ -20,17 +20,11 @@ knitr::opts_chunk$set( [![codecov](https://codecov.io/gh/ACLED/acledR/graph/badge.svg?token=TDJodXhEvx)](https://codecov.io/gh/ACLED/acledR) -Welcome to ACLED's official R package! This package simplifies access to the data via ACLED's API. It also provides convenient functions for making common ACLED data transformations. See dtacled.github.io/acledR for more information and tutorials on how to use the package. -# Overview +Welcome to acledR! This package provides tools to extract and manipulate data from the [Armed Conflict Location and Event Data Project (ACLED)](https://acleddata.com/). It also provides convenient functions for making common ACLED data transformations. See [dtacled.github.io/acledR](https://dtacled.github.io/acledR) for more information and tutorials on how to use the package. -This package provides tools to extract and manipulate data from the [Armed Conflict Location and Event Data Project (ACLED)](https://acleddata.com/). - -To access ACLED data, please register an account at [developer.acleddata.com](developer.acleddata.com). - -* You can visit our [guide](https://acleddata.com/acleddatanew//wp-content/uploads/2021/11/ACLED_Access-Guide_October-2020.pdf) on how to easily set up your ACLED account. -* We recommend you to save your ACLED API Key in an R object so you can easily re-use your key. +To access ACLED data, please register an account at [developer.acleddata.com](https://developer.acleddata.com). You can find detailed instructions for setting up your account and retreiving an API key [here](https://acleddata.com/acleddatanew//wp-content/uploads/2021/11/ACLED_Access-Guide_October-2020.pdf). ## Installation diff --git a/README.md b/README.md index f71f5e3..d6ca29b 100755 --- a/README.md +++ b/README.md @@ -7,74 +7,26 @@ [![R-CMD-check](https://github.com/ACLED/acledR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ACLED/acledR/actions/workflows/R-CMD-check.yaml) [![codecov](https://codecov.io/gh/ACLED/acledR/graph/badge.svg?token=TDJodXhEvx)](https://codecov.io/gh/ACLED/acledR) - -# Overview - -This package provides tools to extract and manipulate data from the -[Armed Conflict Location and Event Data Project -(ACLED)](https://acleddata.com/). +Welcome to acledR! This package provides tools to extract and manipulate +data from the [Armed Conflict Location and Event Data Project +(ACLED)](https://acleddata.com/). It also provides convenient functions +for making common ACLED data transformations. See +[dtacled.github.io/acledR](https://dtacled.github.io/acledR) for more +information and tutorials on how to use the package. To access ACLED data, please register an account at -[developer.acleddata.com](developer.acleddata.com). - -- You can visit our - [guide](https://acleddata.com/acleddatanew//wp-content/uploads/2021/11/ACLED_Access-Guide_October-2020.pdf) - on how to easily set up your ACLED account. -- We recommend you to save your ACLED API Key in an R object so you can - easily re-use your key. - -## Installation (for private repo) - -Since the package repo is currently private, you need to tell R and -Github that you’re a collaborator. To do so, you first create a Github -personal access token (PAT). You can set this to expire after a certain -time (the default) or be permanent. We can initiate this process -internally via: - -``` r -# install.packages("usethis") if not installed already -# create personal access token - this should redirect to your github page where you can copy the token -usethis::create_github_token() -``` - -After you’ve copied the PAT from the browser, return to R and run this, -which will store the PAT locally. - -``` r -# paste the token where it says YourPAT -credentials::set_github_pat("YourPAT") -# if you run this, it should print your token; if not we've failed -Sys.getenv("GITHUB_PAT") -``` - -I recommend also setting the PAT in your `.Rprofile` so it’s stored for -all R sessions (i.e., you don’t have to save the PAT and paste it in -each time you re-install). +[developer.acleddata.com](https://developer.acleddata.com). You can find +detailed instructions for setting up your account and retreiving an API +key +[here](https://acleddata.com/acleddatanew//wp-content/uploads/2021/11/ACLED_Access-Guide_October-2020.pdf). -``` r -# to set your PAT for all R sessions, run -file.edit(file.path("~", ".Rprofile")) -# and then paste credentials::set_github_pat("YourPAT") into the .Rprofile script -# save the file -``` +## Installation -Now you can install the package and it will automatically locate your -PAT. +The package will be reviewed and available on CRAN shortly. In the +meantime, you can install the package from Github: ``` r -# install from github devtools::install_github("ACLED/acledR") ``` - -## Installation (for public use) - -Until the acledR package gets added into the Comprehensive R Archive -Network (CRAN), users can utilize devtools to install the package from -Github. Thankfully, the installation is rather simple. You can install -it through the following code: - -``` r -devtools::install_github("ACLED/acledR") ## if you are interested in a particular branch, please add a 'ref' argument. -``` diff --git a/tests/testthat/setup-acled_access.R b/tests/testthat/setup-acled_access.R index b492d43..f89cda3 100644 --- a/tests/testthat/setup-acled_access.R +++ b/tests/testthat/setup-acled_access.R @@ -1,5 +1,5 @@ # Setup for test acled_access -# Run the function to set up the enviornment credentials +# Run the function to set up the environment credentials acled_access(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY")) diff --git a/tests/testthat/test-acled_access.R b/tests/testthat/test-acled_access.R index 8ee6a78..eeb081a 100644 --- a/tests/testthat/test-acled_access.R +++ b/tests/testthat/test-acled_access.R @@ -2,8 +2,7 @@ # Does it save the credentials in the enviornment? - Missing test_that("acled_access properly stores the credentials", { - # expect_equal(Sys.getenv("acled_email"),"acledexamples@gmail.com") - expect_equal(Sys.getenv("acled_email"),"t.billing@acleddata.com") + expect_equal(Sys.getenv("acled_email"),"acledrexamples@gmail.com") expect_equal(nchar(Sys.getenv("acled_key")), 20) }) diff --git a/tests/testthat/test-acled_api.R b/tests/testthat/test-acled_api.R index d97f2c3..87c5e91 100644 --- a/tests/testthat/test-acled_api.R +++ b/tests/testthat/test-acled_api.R @@ -178,7 +178,7 @@ test_that("Error when one of two countries are wrong",{ ## Test what happens when someone inputs acled_access as TRUE but it includes email and key. ---- test_that("Acled_access is ignored",{ - expect_true(grepl("t.billing", log_received_data_check_credential$email[1])) + expect_true(grepl("acledrexamples", log_received_data_check_credential$email[1])) }) # Test errors from incorrectly input arguments. ---- @@ -305,7 +305,7 @@ test_that("A warning appears that acled_access is being ignored, and the proper expect_message(acled_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), acled_access = T, log = T, inter_numeric = TRUE), regexp = "acled_access is TRUE, but email and key are included in the function. Ignoring acled_access.") - expect_true(grepl("t.billing", alog$email[1])) + expect_true(grepl("acledrexamples", alog$email[1])) }) diff --git a/tests/testthat/test-acled_deletions_api.R b/tests/testthat/test-acled_deletions_api.R index 0262e95..5e52214 100644 --- a/tests/testthat/test-acled_deletions_api.R +++ b/tests/testthat/test-acled_deletions_api.R @@ -22,7 +22,7 @@ test_that("names of columns are correct - unix", { ## Test that email and key are handled appropiately ---- test_that("Email and key are handled as expected without acled_access",{ - expect_true(grepl("t.billing", received_deleted_log$email[1]))} + expect_true(grepl("acledrexamples", received_deleted_log$email[1]))} ) ## Test that acled_access is handled appropiately. ---- @@ -32,7 +32,7 @@ test_that("Email and Key are handled appropiately",{ some_log <- acled_deletions_api(date_deleted = "1658707200", acled_access = T, log = T) - expect_true(grepl("t.billing", some_log$email[1]))} + expect_true(grepl("acledrexamples", some_log$email[1]))} ) ## Date and unix return the same output ---- @@ -90,7 +90,7 @@ test_that("A warning appears that acled_access is being ignored, and the proper expect_message(acled_deletions_api(email = Sys.getenv("EMAIL_ADDRESS_EXAMPLES"), key = Sys.getenv("EXAMPLES_KEY"), date_deleted = "1658707200",acled_access = T, log = T), regexp = "acled_access is TRUE, but email and key are included in the function. Ignoring acled_access.") - expect_true(grepl("t.billing@acleddata.com", alog$email[1])) + expect_true(grepl("acledrexamples@gmail.com", alog$email[1])) }) diff --git a/vignettes/get_started.Rmd b/vignettes/get_started.Rmd index 2fe0cdf..f744f25 100644 --- a/vignettes/get_started.Rmd +++ b/vignettes/get_started.Rmd @@ -1,5 +1,5 @@ --- -title: "Getting Started" +title: "Get Started" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Get Started}