@@ -401,6 +401,94 @@ test_that("All Records -label", {
401
401
expect_match(returned_object2 $ outcome_messages , regexp = expected_outcome_message , perl = TRUE )
402
402
})
403
403
404
+ test_that(" All Records -label header" , {
405
+ testthat :: skip_on_cran()
406
+ expected_data_frame <- structure(list (`Study ID` = c(1 , 2 , 3 , 4 , 5 ), `First Name` = c(" Nutmeg" ,
407
+ " Tumtum" , " Marcus" , " Trudy" , " John Lee" ), `Last Name` = c(" Nutmouse" ,
408
+ " Nutmouse" , " Wood" , " DAG" , " Walker" ), `Street, City, State, ZIP` = c(" 14 Rose Cottage St.\n Kenning UK, 323232" ,
409
+ " 14 Rose Cottage Blvd.\n Kenning UK 34243" , " 243 Hill St.\n Guthrie OK 73402" ,
410
+ " 342 Elm\n Duncanville TX, 75116" , " Hotel Suite\n New Orleans LA, 70115"
411
+ ), `Phone number` = c(" (405) 321-1111" , " (405) 321-2222" , " (405) 321-3333" ,
412
+ " (405) 321-4444" ,
" (405) 321-5555" ),
`E-mail` = c(
" [email protected] " ,
413
+
414
+ ), `Date of birth` = structure(c(12294 , 12121 , - 13051 , - 6269 ,
415
+ - 5375 ), class = " Date" ), `Age (years)` = c(11 , 11 , 80 , 61 , 59
416
+ ), Gender = c(0 , 1 , 1 , 0 , 1 ), `Complete?` = c(2 , 2 , 2 , 2 , 2 ),
417
+ `Height (cm)` = c(7 , 6 , 180 , 165 , 193.04 ), `Weight (kilograms)` = c(1 ,
418
+ 1 , 80 , 54 , 104 ), BMI = c(204.1 , 277.8 , 24.7 , 19.8 , 27.9 ),
419
+ Comments = c(" Character in a book, with some guessing" , " A mouse character from a good book" ,
420
+ " completely made up" , " This record doesn't have a DAG assigned\n\n So call up Trudy on the telephone\n Send her a letter in the mail" ,
421
+ " Had a hand for trouble and a eye for cash\n\n He had a gold watch chain and a black mustache"
422
+ ), Mugshot = c(" [document]" , " [document]" , " [document]" ,
423
+ " [document]" , " [document]" ), `Complete?_1` = c(1 , 0 , 2 , 2 ,
424
+ 0 ), `Race (Select all that apply) (choice=American Indian/Alaska Native)` = c(0 ,
425
+ 0 , 0 , 0 , 1 ), `Race (Select all that apply) (choice=Asian)` = c(0 ,
426
+ 0 , 0 , 1 , 0 ), `Race (Select all that apply) (choice=Native Hawaiian or Other Pacific Islander)` = c(0 ,
427
+ 1 , 0 , 0 , 0 ), `Race (Select all that apply) (choice=Black or African American)` = c(0 ,
428
+ 0 , 1 , 0 , 0 ), `Race (Select all that apply) (choice=White)` = c(1 ,
429
+ 1 , 1 , 1 , 0 ), `Race (Select all that apply) (choice=Unknown / Not Reported)` = c(0 ,
430
+ 0 , 0 , 0 , 1 ), Ethnicity = c(1 , 1 , 0 , 1 , 2 ), `Complete?_2` = c(2 ,
431
+ 0 , 2 , 2 , 2 )), .Names = c(" Study ID" , " First Name" , " Last Name" ,
432
+ " Street, City, State, ZIP" , " Phone number" , " E-mail" , " Date of birth" ,
433
+ " Age (years)" , " Gender" , " Complete?" , " Height (cm)" , " Weight (kilograms)" ,
434
+ " BMI" , " Comments" , " Mugshot" , " Complete?_1" , " Race (Select all that apply) (choice=American Indian/Alaska Native)" ,
435
+ " Race (Select all that apply) (choice=Asian)" , " Race (Select all that apply) (choice=Native Hawaiian or Other Pacific Islander)" ,
436
+ " Race (Select all that apply) (choice=Black or African American)" ,
437
+ " Race (Select all that apply) (choice=White)" , " Race (Select all that apply) (choice=Unknown / Not Reported)" ,
438
+ " Ethnicity" , " Complete?_2" ), row.names = c(NA , - 5L ), class = " data.frame" , spec = structure(list (
439
+ cols = structure(list (`Study ID` = structure(list (), class = c(" collector_double" ,
440
+ " collector" )), `First Name` = structure(list (), class = c(" collector_character" ,
441
+ " collector" )), `Last Name` = structure(list (), class = c(" collector_character" ,
442
+ " collector" )), `Street, City, State, ZIP` = structure(list (), class = c(" collector_character" ,
443
+ " collector" )), `Phone number` = structure(list (), class = c(" collector_character" ,
444
+ " collector" )), `E-mail` = structure(list (), class = c(" collector_character" ,
445
+ " collector" )), `Date of birth` = structure(list (format = " " ), .Names = " format" , class = c(" collector_date" ,
446
+ " collector" )), `Age (years)` = structure(list (), class = c(" collector_double" ,
447
+ " collector" )), Gender = structure(list (), class = c(" collector_double" ,
448
+ " collector" )), `Complete?` = structure(list (), class = c(" collector_double" ,
449
+ " collector" )), `Height (cm)` = structure(list (), class = c(" collector_double" ,
450
+ " collector" )), `Weight (kilograms)` = structure(list (), class = c(" collector_double" ,
451
+ " collector" )), BMI = structure(list (), class = c(" collector_double" ,
452
+ " collector" )), Comments = structure(list (), class = c(" collector_character" ,
453
+ " collector" )), Mugshot = structure(list (), class = c(" collector_character" ,
454
+ " collector" )), `Complete?_1` = structure(list (), class = c(" collector_double" ,
455
+ " collector" )), `Race (Select all that apply) (choice=American Indian/Alaska Native)` = structure(list (), class = c(" collector_double" ,
456
+ " collector" )), `Race (Select all that apply) (choice=Asian)` = structure(list (), class = c(" collector_double" ,
457
+ " collector" )), `Race (Select all that apply) (choice=Native Hawaiian or Other Pacific Islander)` = structure(list (), class = c(" collector_double" ,
458
+ " collector" )), `Race (Select all that apply) (choice=Black or African American)` = structure(list (), class = c(" collector_double" ,
459
+ " collector" )), `Race (Select all that apply) (choice=White)` = structure(list (), class = c(" collector_double" ,
460
+ " collector" )), `Race (Select all that apply) (choice=Unknown / Not Reported)` = structure(list (), class = c(" collector_double" ,
461
+ " collector" )), Ethnicity = structure(list (), class = c(" collector_double" ,
462
+ " collector" )), `Complete?_2` = structure(list (), class = c(" collector_double" ,
463
+ " collector" ))), .Names = c(" Study ID" , " First Name" , " Last Name" ,
464
+ " Street, City, State, ZIP" , " Phone number" , " E-mail" , " Date of birth" ,
465
+ " Age (years)" , " Gender" , " Complete?" , " Height (cm)" , " Weight (kilograms)" ,
466
+ " BMI" , " Comments" , " Mugshot" , " Complete?_1" , " Race (Select all that apply) (choice=American Indian/Alaska Native)" ,
467
+ " Race (Select all that apply) (choice=Asian)" , " Race (Select all that apply) (choice=Native Hawaiian or Other Pacific Islander)" ,
468
+ " Race (Select all that apply) (choice=Black or African American)" ,
469
+ " Race (Select all that apply) (choice=White)" , " Race (Select all that apply) (choice=Unknown / Not Reported)" ,
470
+ " Ethnicity" , " Complete?_2" )), default = structure(list (), class = c(" collector_guess" ,
471
+ " collector" ))), .Names = c(" cols" , " default" ), class = " col_spec" ))
472
+
473
+ expected_warning <- " Duplicated column names deduplicated: 'Complete\\ ?' => 'Complete\\ ?_1' \\ [16\\ ], 'Complete\\ ?' => 'Complete\\ ?_2' \\ [24\\ ]"
474
+ expected_outcome_message <- " 5 records and 24 columns were read from REDCap in \\ d+(\\ .\\ d+\\ W|\\ W)seconds\\ ."
475
+
476
+ expect_warning(
477
+ regexp = expected_warning ,
478
+ expect_message(
479
+ regexp = expected_outcome_message ,
480
+ returned_object <- redcap_read(redcap_uri = credential $ redcap_uri , token = credential $ token , raw_or_label_headers = " label" )
481
+ )
482
+ )
483
+
484
+ expect_equivalent(returned_object $ data , expected = expected_data_frame , label = " The returned data.frame should be correct" ) # dput(returned_object$data)
485
+ expect_match(returned_object $ status_codes , regexp = " 200" , perl = TRUE )
486
+ expect_true(returned_object $ records_collapsed == " " , " A subset of records was not requested." )
487
+ expect_true(returned_object $ fields_collapsed == " " , " A subset of fields was not requested." )
488
+ expect_match(returned_object $ outcome_message , regexp = expected_outcome_message , perl = TRUE )
489
+ expect_true(returned_object $ success )
490
+ })
491
+
404
492
test_that(" Filter - numeric" , {
405
493
testthat :: skip_on_cran()
406
494
expected_data_frame <- structure(
0 commit comments