nc-minibbs / mbbs

A repository for the Mini-Bird Breeding Survey data
https://minibbs.us
Other
2 stars 0 forks source link

87 observers ver 3 #91

Closed IJBG closed 2 months ago

IJBG commented 2 months ago

Draft right now because I'm having errors with the testing I'm not quite sure how to solve..

In the meantime, primary_observer has been updated to it's third version see #87

The update_conversion_table function, update_mini_table, and update_survey_events have been reworked and simplified. Now, there's less manual input needed when new observers join the project or current observers survey a new route for the first time. Additionally, survey_list and survey_events update whenever new routes are added, or routes are updated (eg. a previously unuploaded stop gets uploaded to ebird).

IJBG commented 2 months ago

Tests run fine using devtools::test(), it's when the tests are run while using devtools::check() that they fail. Having problems with the save and loading of .rda files.

Error: `══ Warnings ════════════════════════════════════════════════════════════════════ ── Warning ('test_process_observers.R:8:3'): update_survey_events runs without error ── cannot open compressed file '', probable reason 'Invalid argument' Backtrace: ▆

  1. ├─testthat::expect_no_error(update_survey_events()) at test_process_observers.R:8:2
  2. │ └─testthat:::expectno(...)
  3. │ └─testthat:::quasi_capture(enquo(object), NULL, capture)
  4. │ ├─testthat (local) .capture(...)
  5. │ │ └─rlang::try_fetch(...)
  6. │ │ ├─base::tryCatch(...)
  7. │ │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  8. │ │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9. │ │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
    1. │ │ └─base::withCallingHandlers(...)
    2. │ └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    3. └─mbbs:::update_survey_events()
    4. └─base::load(file = system.file("data/mbbs.rda", package = "mbbs"))
    5. └─base::readChar(con, 5L, useBytes = TRUE) ── Warning ('test_process_observers.R:21:3'): mbbs_survey_events has no rows with NA observers ── cannot open compressed file '', probable reason 'Invalid argument' Backtrace: ▆
    6. └─base::load(system.file("data/mbbs_survey_events.rda", package = "mbbs")) at test_process_observers.R:21:2
    7. └─base::readChar(con, 5L, useBytes = TRUE) ── Warning ('test_process_observers.R:41:3'): update_observer_table runs without error ── cannot open compressed file '', probable reason 'Invalid argument' Backtrace: ▆
    8. └─base::load(file = system.file("data/mbbs_orange.rda", package = "mbbs")) at test_process_observers.R:41:2
    9. └─base::readChar(con, 5L, useBytes = TRUE)

══ Failed tests ════════════════════════════════════════════════════════════════ ── Failure ('test_process_observers.R:8:3'): update_survey_events runs without error ── Expected update_survey_events() to run without any errors. i Actually got a with text: cannot open the connection ── Error ('test_process_observers.R:21:3'): mbbs_survey_events has no rows with NA observers ── Error in readChar(con, 5L, useBytes = TRUE): cannot open the connection Backtrace: ▆

  1. └─base::load(system.file("data/mbbs_survey_events.rda", package = "mbbs")) at test_process_observers.R:21:2
  2. └─base::readChar(con, 5L, useBytes = TRUE) ── Error ('test_process_observers.R:41:3'): update_observer_table runs without error ── Error in readChar(con, 5L, useBytes = TRUE): cannot open the connection Backtrace: ▆
  3. └─base::load(file = system.file("data/mbbs_orange.rda", package = "mbbs")) at test_process_observers.R:41:2
  4. └─base::readChar(con, 5L, useBytes = TRUE)

[ FAIL 3 | WARN 3 | SKIP 0 | PASS 29 ] Error: Test failures Execution halted`

bsaul commented 2 months ago

Having problems with the save and loading of .rda files.

Are these files created by some function and then tested against?

IJBG commented 2 months ago

Having problems with the save and loading of .rda files.

Are these files created by some function and then tested against?

These files are created by update_survey_events, and I'm trying to check that it runs by testing the whole function with expect_no_error(). But maybe I should just remove this test, as I then check in the next test on that the file was created properly and doesn't have any NA observers.

IJBG commented 2 months ago

Yess! Testing successes 🎉 I removed the test that was having the lingering loading/saving problem and instead evaluate mbbs_survey_events.rda after it's finished processing. I'm happy with this solution - I don't think any NA observers are going to slip through this pipeline. Ready for a review and then post-any-fixes merge

bsaul commented 2 months ago

These files are created by update_survey_events, and I'm trying to check that it runs by testing the whole function with expect_no_error().

Yes that would be difficult to test as it would require reloading the package after the function is called.