Skip to content

Commit

Permalink
add some tests for bulk data in parameter checking
Browse files Browse the repository at this point in the history
  • Loading branch information
datapumpernickel committed May 10, 2024
1 parent 9d87c0c commit a57c2bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/testthat/test-ct_check_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test_that("check_freq returns correct frequency codes and handles invalid inputs
# Test 'check_clCode' function
test_that("check_clCode returns correct classification codes and handles invalid inputs", { #nolint
expect_equal(check_clCode("C", "HS", bulk = FALSE), "HS")
expect_equal(check_clCode("C", "H5", bulk = TRUE), "H5")
expect_equal(check_clCode("C", "B4", bulk = FALSE), "B4")
expect_error(check_clCode("C", "ISIC", bulk = FALSE),
"`commodity_classification` must be one of")
Expand Down Expand Up @@ -160,14 +161,20 @@ test_that("check_customsCode works correctly", {

test_that("check_date works correctly", {
expect_equal(check_date(2010, 2011, "A", bulk = FALSE), "2010,2011")
expect_equal(check_date(2010, 2011, "A", bulk = TRUE), "2010,2011")
expect_equal(check_date(2000, 2024, "A", bulk = TRUE), "2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024")
expect_equal(check_date(2010, 2010, "A", bulk = FALSE), "2010")
expect_equal(check_date("2010-01", "2010-07", "M", bulk = FALSE),
"201001,201002,201003,201004,201005,201006,201007")
expect_equal(check_date("2010-01", "2020-01", "M", bulk = TRUE),
"201001,201002,201003,201004,201005,201006,201007,201008,201009,201010,201011,201012,201101,201102,201103,201104,201105,201106,201107,201108,201109,201110,201111,201112,201201,201202,201203,201204,201205,201206,201207,201208,201209,201210,201211,201212,201301,201302,201303,201304,201305,201306,201307,201308,201309,201310,201311,201312,201401,201402,201403,201404,201405,201406,201407,201408,201409,201410,201411,201412,201501,201502,201503,201504,201505,201506,201507,201508,201509,201510,201511,201512,201601,201602,201603,201604,201605,201606,201607,201608,201609,201610,201611,201612,201701,201702,201703,201704,201705,201706,201707,201708,201709,201710,201711,201712,201801,201802,201803,201804,201805,201806,201807,201808,201809,201810,201811,201812,201901,201902,201903,201904,201905,201906,201907,201908,201909,201910,201911,201912,202001") #nolint
expect_error(check_date("2010-01", "2011-07", "M", bulk = FALSE),
"If specifying years/months, cannot search more than twelve consecutive years/months in a single query.") # nolint
expect_error(check_date("2010-01", "2011-07", "M", bulk = FALSE))
expect_error(check_date("2010-01", "2011", "M", bulk = FALSE),
"If arg 'frequency' is 'monthly', 'start_date' and 'end_date' must have the same format.") # nolint
expect_error(check_date("2010-01", "2011", "M", bulk = TRUE),
"If arg 'frequency' is 'monthly', 'start_date' and 'end_date' must have the same format.") # nolint
})

test_that("convert_to_date works correctly", {
Expand Down

0 comments on commit a57c2bc

Please sign in to comment.