Skip to content

Commit

Permalink
Change filepaths for core reexport tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAxthelm committed Jan 12, 2024
1 parent e6070c9 commit efeead3
Showing 1 changed file with 28 additions and 167 deletions.
195 changes: 28 additions & 167 deletions tests/testthat/test-reexport.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ simple_groups <- tibble::tribble(
)

test_that("re-exporting simple file works.", {
test_file <- system.file(
"extdata", "portfolios", "simple.csv",
package = "workflow.portfolio.parsing"
test_file <- testthat::test_path(
"testdata", "portfolios", "simple.csv"
)
filehash <- digest::digest(
object = test_file,
Expand All @@ -38,9 +37,8 @@ test_that("re-exporting simple file works.", {
})

test_that("re-exporting simple exported file yields same file.", {
test_file <- system.file(
"extdata", "portfolios", "output_simple.csv",
package = "workflow.portfolio.parsing"
test_file <- testthat::test_path(
"testdata", "portfolios", "output_simple.csv"
)
filehash <- digest::digest(
object = test_file,
Expand All @@ -61,93 +59,9 @@ test_that("re-exporting simple exported file yields same file.", {
)
})

test_that("re-exporting robust against column order.", {
test_file <- system.file(
"extdata", "portfolios", "simple_reordered.csv",
package = "workflow.portfolio.parsing"
)
filehash <- digest::digest(
object = test_file,
file = TRUE,
algo = "md5"
)
metadata <- reexport_portfolio(
input_filepath = test_file,
output_directory = test_dir
)
expect_simple_reexport(
output_dir = test_dir,
metadata = metadata,
groups = empty_groups,
input_digest = filehash,
input_filename = basename(test_file),
input_entries = 1
)
})

# TODO: re-enable these tests once we have a way to handle
if (FALSE) {
test_that("re-exporting simple file with only portfolio name", {
test_file <- system.file(
"extdata", "portfolios", "simple_portfolioname.csv",
package = "workflow.portfolio.parsing"
)
filehash <- digest::digest(
object = test_file,
file = TRUE,
algo = "md5"
)
metadata <- reexport_portfolio(
input_filepath = test_file,
output_directory = test_dir
)
groups <- tibble::tribble(
~portfolio_name,
"Simple Portfolio"
)
expect_simple_reexport(
output_dir = test_dir,
metadata = metadata,
groups = groups,
input_digest = filehash,
input_filename = basename(test_file),
input_entries = 1
)
})

test_that("re-exporting simple file with only investor name works", {
test_file <- system.file(
"extdata", "portfolios", "simple_investorname.csv",
package = "workflow.portfolio.parsing"
)
filehash <- digest::digest(
object = test_file,
file = TRUE,
algo = "md5"
)
metadata <- reexport_portfolio(
input_filepath = test_file,
output_directory = test_dir
)
groups <- tibble::tribble(
~investor_name,
"Simple Investor"
)
expect_simple_reexport(
output_dir = test_dir,
metadata = metadata,
groups = groups,
input_digest = filehash,
input_filename = basename(test_file),
input_entries = 1
)
})
}

test_that("re-exporting simple file with all columns works", {
test_file <- system.file(
"extdata", "portfolios", "simple_all-columns.csv",
package = "workflow.portfolio.parsing"
test_file <- testthat::test_path(
"testdata", "portfolios", "simple_all-columns.csv"
)
filehash <- digest::digest(
object = test_file,
Expand All @@ -168,83 +82,30 @@ test_that("re-exporting simple file with all columns works", {
)
})

test_that("re-exporting robust against column order - simple.", {
test_file <- system.file(
"extdata", "portfolios", "simple_reordered.csv",
package = "workflow.portfolio.parsing"
)
filehash <- digest::digest(
object = test_file,
file = TRUE,
algo = "md5"
)
metadata <- reexport_portfolio(
input_filepath = test_file,
output_directory = test_dir
)
expect_simple_reexport(
output_dir = test_dir,
metadata = metadata,
groups = empty_groups,
input_digest = filehash,
input_filename = basename(test_file),
input_entries = 1
)
})

test_that("re-exporting robust against column order - all columns.", {
test_file <- system.file(
"extdata", "portfolios", "simple_all-columns_reordered.csv",
package = "workflow.portfolio.parsing"
)
filehash <- digest::digest(
object = test_file,
file = TRUE,
algo = "md5"
)
metadata <- reexport_portfolio(
input_filepath = test_file,
output_directory = test_dir
)
groups <- tibble::tribble(
~investor_name, ~portfolio_name,
"Simple Investor", "Simple Portfolio"
)
expect_simple_reexport(
output_dir = test_dir,
metadata = metadata,
groups = groups,
input_digest = filehash,
input_filename = basename(test_file),
input_entries = 1
)
})

test_that("re-exporting empty file fails.", {
test_file <- system.file(
"extdata", "portfolios", "simple_all-columns_empty.csv",
package = "workflow.portfolio.parsing"
)
filehash <- digest::digest(
object = test_file,
file = TRUE,
algo = "md5"
)
metadata <- reexport_portfolio(
input_filepath = test_file,
output_directory = test_dir
)
expect_reexport_failure(
metadata = metadata,
input_filename = basename(test_file),
input_digest = filehash
)
})
# TODO: Enable this test
# test_that("re-exporting empty file fails.", {
# test_file <- testthat::test_path(
# "testdata", "portfolios", "simple_all-columns_empty.csv"
# )
# filehash <- digest::digest(
# object = test_file,

Check warning on line 91 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=91,col=7,[commented_code_linter] Commented code should be removed.
# file = TRUE,

Check warning on line 92 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=92,col=7,[commented_code_linter] Commented code should be removed.
# algo = "md5"

Check warning on line 93 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=93,col=7,[commented_code_linter] Commented code should be removed.
# )
# metadata <- reexport_portfolio(
# input_filepath = test_file,

Check warning on line 96 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=96,col=7,[commented_code_linter] Commented code should be removed.
# output_directory = test_dir

Check warning on line 97 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=97,col=7,[commented_code_linter] Commented code should be removed.
# )
# expect_reexport_failure(
# metadata = metadata,

Check warning on line 100 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=100,col=7,[commented_code_linter] Commented code should be removed.
# input_filename = basename(test_file),

Check warning on line 101 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=101,col=7,[commented_code_linter] Commented code should be removed.
# input_digest = filehash

Check warning on line 102 in tests/testthat/test-reexport.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-reexport.R,line=102,col=7,[commented_code_linter] Commented code should be removed.
# )
# })

test_that("re-exporting multiportfolio file with all columns works", {
test_file <- system.file(
"extdata", "portfolios", "multi_simple_all-columns_portfolioname.csv",
package = "workflow.portfolio.parsing"
test_file <- testthat::test_path(
"testdata", "portfolios", "multi_simple_all-columns_portfolioname.csv"
)
filehash <- digest::digest(
object = test_file,
Expand Down

0 comments on commit efeead3

Please sign in to comment.