Skip to content

Commit

Permalink
Add test around UpdatedLHTPicker class
Browse files Browse the repository at this point in the history
  • Loading branch information
d2gex committed Apr 5, 2024
1 parent fc1d082 commit 6611c01
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/testthat/test-updated_lht_picker.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
test_that("Pick updated LHT values given new data at once", {
u_lht_picker <- UpdatedLHTPicker$new(
testing_db,
wanted_update_taxon_details ,
fishlife_context$updated_prefix,
fishlife_context$transform_function_list,
fishlife_context$backtransform_function_list,
fishlife_context$lht_names
)
updated_lht_df <- u_lht_picker$pick_and_transform()
non_logarithmic_scale <- 10

expect_true(nrow(updated_lht_df) == 2)
expect_true(any(!is.na(updated_lht_df[updated_lht_df$taxon == 'Trisopterus luscus',])))
expect_true(any(!is.na(updated_lht_df[updated_lht_df$taxon == 'Pollachius pollachius',])))

# Ensure values have been backtransformed
expect_true(updated_lht_df[updated_lht_df$taxon == 'Trisopterus luscus', 'Linf'] > non_logarithmic_scale)
expect_true(updated_lht_df[updated_lht_df$taxon == 'Pollachius pollachius', 'Linf'] > non_logarithmic_scale)
expect_equal(updated_lht_df[updated_lht_df$taxon == 'Trisopterus luscus', 'updated_Linf'], 44.24, tolerance = 0.01)
})

0 comments on commit 6611c01

Please sign in to comment.