Skip to content

Commit

Permalink
Merge pull request #2 from Metropolitan-Council/1-public-repo-prep
Browse files Browse the repository at this point in the history
Public repository prep
  • Loading branch information
eroten authored Nov 1, 2022
2 parents fcb3632 + 2a5b493 commit de8367a
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 78 deletions.
4 changes: 3 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

This project uses a [feature-branch](https://deepsource.io/blog/git-branch-naming-conventions/) naming convention and workflow.

`main` is the main branch (not `master`), base your work off of `main`.
We highly suggest you take the time to set up commit [signing](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) with GPG.

`main` is the main branch. Base your work off of `main`.
Contribute to the project by making changes to your own feature branch and issuing pull-requests when you're ready to integrate into the `main` branch:

* Pull the `main` branch; `git pull`, and if necessary `git checkout main` to switch to `main`
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

STREETLIGHTR_KEY: ${{ secrets.STREETLIGHTR_KEY }}

steps:
- uses: actions/checkout@v3

Expand Down
10 changes: 6 additions & 4 deletions R/create_streetlight_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,12 @@ create_streetlight_analysis <- function(login_email,
httr2::req_perform()

# return message based on response
if (!httr2::resp_status_desc(resp) %in% c("success",
"created",
"Success",
"Created")) {
if (!httr2::resp_status_desc(resp) %in% c(
"success",
"created",
"Success",
"Created"
)) {
return(cli::cli_warn(c(
"Create analysis failed with message:",
httr2::resp_body_json(resp)
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ knitr::opts_chunk$set(echo = TRUE, eval = FALSE)
<!-- badges: end -->


R wrapper for StreetLight Insights API.
R wrapper for StreetLight InSight® API.

IMPORTANT: This package is not affiliated with nor maintained by [StreetLight Data](https://www.streetlightdata.com/). This package is tool for StreetLight API users authored by StreetLight API users.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
status](https://github.com/Metropolitan-Council/streetlightR/workflows/R-CMD-check/badge.svg)](https://github.com/Metropolitan-Council/streetlightR/actions)
<!-- badges: end -->

R wrapper for StreetLight Insights API.
R wrapper for StreetLight InSight® API.

IMPORTANT: This package is not affiliated with nor maintained by
[StreetLight Data](https://www.streetlightdata.com/). This package is
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
suppressMessages(
streetlightR::streetlight_api_key(
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
)
)
)

test_login <- httr2::secret_decrypt(
"Q8yxP3atCs0CbbM_C3VBArmMQpNlcAPAlbRfNR_nBxVT0mcOyi7dLKxB",
key = "STREETLIGHTR_KEY"
)

8 changes: 1 addition & 7 deletions tests/testthat/test-check_analysis_status.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
testthat::skip_on_ci()

testthat::test_that("Analysis status correct", {
status <- check_analysis_status(
analysis_name_ = "testing4",
key = httr2::secret_decrypt("Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
)
) %>%
analysis_name_ = "testing4") %>%
testthat::expect_warning()

avail <- status$status
Expand Down
37 changes: 6 additions & 31 deletions tests/testthat/test-check_date_range.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
testthat::test_that("Default travel mode date range returns table", {
testthat::expect_true(
tibble::is_tibble(
check_date_range(
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
)
)
check_date_range()
)
)
})
Expand All @@ -17,11 +12,7 @@ testthat::test_that("Bike date range returns table", {
testthat::expect_true(
tibble::is_tibble(
check_date_range(
travel_mode_type = "Bicycle",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
)
travel_mode_type = "Bicycle"
)
)
)
Expand All @@ -33,12 +24,8 @@ testthat::test_that("Truck date range returns table", {
testthat::expect_true(
tibble::is_tibble(
check_date_range(
travel_mode_type = "Truck",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
travel_mode_type = "Truck"
)
)
)
)
})
Expand All @@ -49,11 +36,7 @@ testthat::test_that("Pedestrian date range returns table", {
testthat::expect_true(
tibble::is_tibble(
check_date_range(
travel_mode_type = "Pedestrian",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
)
travel_mode_type = "Pedestrian"
)
)
)
Expand All @@ -65,12 +48,8 @@ testthat::test_that("Bus date range returns table", {
testthat::expect_true(
tibble::is_tibble(
check_date_range(
travel_mode_type = "Bus",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
travel_mode_type = "Bus"
)
)
)
)
})
Expand All @@ -80,12 +59,8 @@ testthat::test_that("Rail date range returns table", {
testthat::expect_true(
tibble::is_tibble(
check_date_range(
travel_mode_type = "Rail",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
travel_mode_type = "Rail"
)
)
)
)
})
3 changes: 2 additions & 1 deletion tests/testthat/test-check_streetlight_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Sys.sleep(1)
testthat::test_that("API key test retuns value", {
testthat::expect_equal(
check_streetlight_api(
key = httr2::secret_decrypt("Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
)
),
Expand Down
9 changes: 1 addition & 8 deletions tests/testthat/test-create_analysis.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@

testthat::test_that("Expected warning returned", {
testthat::expect_warning(create_streetlight_analysis(
login_email = httr2::secret_decrypt(
"Q8yxP3atCs0CbbM_C3VBArmMQpNlcAPAlbRfNR_nBxVT0mcOyi7dLKxB",
key = "STREETLIGHTR_KEY"
),
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
),
login_email = test_login,
analysis_type = "Zone_Activity_Analysis",
analysis_name = "v220311-VMT 2019 month 1 Volume Trip Trav Attr",
travel_mode_type = "All_Vehicles",
Expand Down
6 changes: 0 additions & 6 deletions tests/testthat/test-get_analysis_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
testthat::test_that("VMT download is returned", {
get_analysis_data(
analysis_name_ = "v221017-VMT 2022 month 4 Volume Trip Trav Attr",
key = httr2::secret_decrypt("Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
),
metric = "zad"
) %>%
testthat::expect_warning() %>%
Expand All @@ -16,9 +13,6 @@ Sys.sleep(0.5)
testthat::test_that("Rate limit hit", {
get_analysis_data(
analysis_name = "v221017-VMT 2022 month 4 Volume Trip Trav Attr",
key = httr2::secret_decrypt("Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
),
metric = "zone_trip_all"
) %>%
testthat::expect_error()
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-streetlight_insight.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
test_that("correct class return", {
streetlight_insight(
endpoint = "analyses",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
),
endpoint = "analyses"
)

) %>%
testthat::expect_s3_class("httr2_request")
})
Expand All @@ -18,11 +19,11 @@ test_that("error on no key", {

test_that("error on bad endpoint", {
streetlight_insight(
endpoint = "cats",
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
),
endpoint = "cats"
)
) %>%
httr2::req_perform() %>%
testthat::expect_error()
Expand Down
9 changes: 1 addition & 8 deletions tests/testthat/test-upload_zone_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ testthat::test_that("Correct warning returned", {
sf::st_buffer(20)

upload_zone_set(
login_email = httr2::secret_decrypt(
"Q8yxP3atCs0CbbM_C3VBArmMQpNlcAPAlbRfNR_nBxVT0mcOyi7dLKxB",
key = "STREETLIGHTR_KEY"
),
key = httr2::secret_decrypt(
"Zj4CCBvezhp3MoouyMxfmO7Htc6AVlwkBIB1va7ISjXOXS8PfexLOGCZiE5_wQFu",
key = "STREETLIGHTR_KEY"
),
login_email = test_login,
geom_type = "polygon",
zones = example_polygon,
zone_set_name = "testing"
Expand Down
9 changes: 4 additions & 5 deletions vignettes/api_zaa.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ upload_zone_set(
login_email = your_email,
geom_type = "polygon",
zones = example_polygon,
zone_set_name = name)
zone_set_name = name
)
```

## Create a streetlight analysis
Expand All @@ -50,7 +49,7 @@ upload_zone_set(
create_streetlight_analysis(
login_email = your_email,
analysis_type = "Zone_Activity_Analysis",
analysis_name = "blah2", #name,
analysis_name = "blah2", # name,
travel_mode_type = "All_Vehicles",
output_type = "Volume",
origin_zone_set = name,
Expand All @@ -68,7 +67,7 @@ create_streetlight_analysis(

```{r}
check_analysis_status(
analysis_name = name,
analysis_name = name,
)
results <- get_analysis_data(
Expand Down

0 comments on commit de8367a

Please sign in to comment.