Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit testing #27

Merged
merged 62 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
de6d40a
Restyle using styler::tidyverse_style()
Oct 25, 2022
b6bf66c
Remove commented code
Oct 25, 2022
b8bc838
Change variables and fxn names to snake_case
Oct 25, 2022
780d978
Eliminate use of getwd
Oct 25, 2022
d90f1fc
Refactor load_data
Oct 25, 2022
bef93d8
Allll the refactoring
Oct 26, 2022
4277b30
Change test_field_num to test_fields_match
Oct 27, 2022
8d772b2
Update return value documentation
Oct 27, 2022
bc9ab0c
Update gitignore
Oct 27, 2022
35eba95
Fix logical operators
Oct 27, 2022
6646e7d
In test_file_name_match, handle case where only one data table
Oct 27, 2022
7fab2ab
Merge branch 'main' into refactoring
Oct 27, 2022
50d570f
Add script to try out tests
Oct 27, 2022
148f35d
First stab at testing numeric fields
Oct 27, 2022
9efc4f8
Typo fix
Oct 27, 2022
03c3ed5
Add ability to use magrittr pipes
Oct 31, 2022
526d842
Fix test_fields_match()
Oct 31, 2022
b0e0c11
Add comments to testing script
Oct 31, 2022
b761f0f
Add date range check.
Nov 4, 2022
a36960e
Documentation tweak
Nov 4, 2022
5f286e2
Add function for converting EML datetime format strings to R-compatib…
Nov 4, 2022
7e2ce10
Update documentation for convert_datetime_format
Nov 4, 2022
8bba851
Improvements to test_date_range
Nov 4, 2022
f69271b
Update authors/contributors
Nov 9, 2022
c47d4fd
Update test_date_range
Nov 9, 2022
2cba090
Update temporary testing script
Nov 9, 2022
0dc79d0
Refactoring
Nov 9, 2022
8aaa61e
Fixes to test_date_range
Nov 15, 2022
a4b68dc
Use cli package to format messages/warnings/errors
Nov 15, 2022
942b6bf
Add testthat framework
Nov 18, 2022
5231532
Add imports
Nov 18, 2022
3c42285
Fixes to load_metadata
Nov 18, 2022
007ab42
Add tests for load_metadata
Nov 18, 2022
2f467f4
Update EMLeditor fxn names
Dec 1, 2022
592b2fd
Update example files for testing
Dec 5, 2022
ca2e270
Add tests
Dec 5, 2022
15463ad
Add option to suppress message from load_metadata
Dec 6, 2022
6e1a3a6
Handle case where numeric_version() can't parse version
Dec 6, 2022
1b5ae6c
Fix test_header_num and test_delimiter to handle case when some (but …
Dec 6, 2022
315e456
Minor fix to test_dup_meta_entries, delete test_dup_data_files
Dec 7, 2022
1e78d6a
Minor fixes to test_file_name_match and test_fields_match
Dec 7, 2022
d8f82ca
Fix test_date_range to identify columns where some but not all dates …
Dec 7, 2022
33e69a1
Add unit tests
Dec 7, 2022
4862a43
Fix tests
Dec 14, 2022
0639867
Fix R CMD check issues, add github actions for test coverage, R CMD c…
Dec 14, 2022
978c8e1
Try github actions again, on current branch this time
Dec 14, 2022
d087844
Remove duplicate badge
Dec 14, 2022
0c47db8
Attempted bugfix in pkgdown action
Dec 14, 2022
caade01
Fix arcticdatautils import
Dec 14, 2022
d426350
Get rid of non-pkgdown actions, try another pkgdown fix
Dec 14, 2022
ffbe9bc
Maybe this time
Dec 14, 2022
7a39d4f
Manually create pkgdown site
Dec 14, 2022
279da58
remove docs from gitignore
Dec 14, 2022
2675a9e
Make search for files ending in "metadata.xml" non-case-sensitive
Dec 15, 2022
988b705
Add run_congruence_checks to run all checks at once
Dec 15, 2022
17a7778
Bugfix
Dec 15, 2022
59084ee
Update DESCRIPTION
Dec 15, 2022
5150b43
Documentation for run_congruence_checks
Dec 15, 2022
0c9f9b5
Add tests for run_congruence_check
Dec 15, 2022
939f406
Clean up author info
Dec 15, 2022
7bc112f
Update pkgdown site
Dec 15, 2022
f0e1248
Resolve merge conflicts
Dec 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
^\.Rproj\.user$
^DPchecker\.Rproj$
^LICENSE\.md$
^\.github$
^_pkgdown\.yml$
^docs$
^pkgdown$
28 changes: 20 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
Package: DPchecker
Title: Checks Data Packages for Congruence
Version: 0.0.0.9000
Author:
person("Rob", "Baker", , "robert_baker@nps.gov", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-7591-5035"))
Maintainer: rob baker <robert_baker@nps.gov>
Version: 0.1.0
Authors@R: c(
person("Rob", "Baker", email = "robert_baker@nps.gov", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-7591-5035")),
person(c("Sarah", "E."), "Wright", email = "sarah_wright@nps.gov", role = "aut"),
person("Issac", "Quevedo", role = "ctb"),
person("Amelia", "Sherman", role = "ctb"))
Description: Allows the user (and reviewer) to check a data package and test whether it meets the congruence standards set forth by NPS for upload to DataStore as a datapackage.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
Suggests:
here,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Imports:
arcticdatautils (>= 0.7.0),
crayon,
here,
EML,
readr
readr,
magrittr,
lubridate,
EMLeditor (>= 0.0.1.0),
cli,
dplyr,
purrr,
stringr,
tibble
Remotes:
nationalparkservice/EMLeditor,
https://github.com/NCEAS/arcticdatautils
URL: https://nationalparkservice.github.io/DPchecker/
7 changes: 6 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Generated by roxygen2: do not edit by hand

export(DPchecker_example)
export(convert_datetime_format)
export(load_data)
export(load_metadata)
export(run_congruence_checks)
export(test_date_range)
export(test_delimiter)
export(test_dup_data_files)
export(test_dup_meta_entries)
export(test_fields_match)
export(test_file_name_match)
export(test_footer)
export(test_header_num)
export(test_metadata_version)
export(test_numeric_fields)
export(test_validate_schema)
importFrom(magrittr,"%>%")
7 changes: 7 additions & 0 deletions R/DPchecker-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
#' @importFrom magrittr %>%
## usethis namespace: end
NULL
670 changes: 585 additions & 85 deletions R/tabular_data_congruence.R

Large diffs are not rendered by default.

32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

# DPchecker

#### v0.0.0.9000
#### v0.1.0

DPchecker (Data Package checker) is a package with a series of functions for NPS data package authors and reviewers to check for internal consistency among data/meta data and with the data package standards.

Currently, *only EML metadata and .csv data files* are supported. All data files and the single metadata file (named *_metadata.xml) must be in the same directory.
Currently, *only EML metadata and .csv data files* are supported. It is recommended that you store all data files and the single metadata file (filename must end in "metadata.xml") in the same directory.

Each function runs an individual test and imports data or metadata as necessary. At some point these functions will be inserted in to a wrapper that will run all the tests and import data/metadata only once.
Each function runs an single check and imports data or metadata as necessary. If you prefer to run all checks at once, you can use `run_congruence_checks()`.

## Installation
You can install the development version of DPchecker from
Expand All @@ -20,16 +20,32 @@ devtools::install_github("nationalparkservice/DPchecker")
```

## Examples:
Check whether your metadata are schema-valid:
Run all checks at once:

``` r
library(DPchecker)

# If you set your working directory to the directory with your data package data files (including metadata):
# Get the directory where example data is stored (alternately, replace this with the path to your data folder)

test.validateSchema()
dir <- DPchecker_example("BICY_veg") # Use this to test things out with the included example data
# dir <- "C:/Users/yourusername/Documents/my_data_package" # The path to your data package should look something like this

# Alternatively, you can supply the path to the data package data files (including metadata) without changing your working directory:
# Run all checks and summarize results

test.validateSchema("C:/user/documents/mydatapackage")
run_congruence_checks(dir)

# Alternately, if your data package is stored in the root of your R project folder, you don't need to pass any arguments
run_congruence_checks()
```

Verify that file names and column names in the metadata match the data:

``` r
library(DPchecker)

dir <- DPchecker_example("BICY_veg") # Use this to test things out with the included example data
# dir <- "C:/Users/yourusername/Documents/my_data_package" # The path to your data package should look something like this

test_file_name_match(dir)
test_fields_match(dir)
```
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: ~
template:
bootstrap: 5

80 changes: 80 additions & 0 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading