Skip to content

Commit

Permalink
Merge pull request #27 from nationalparkservice/unit-testing
Browse files Browse the repository at this point in the history
Unit testing
  • Loading branch information
wright13 authored Dec 15, 2022
2 parents 18173d3 + f0e1248 commit 1c74663
Show file tree
Hide file tree
Showing 115 changed files with 174,476 additions and 161 deletions.
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

0 comments on commit 1c74663

Please sign in to comment.