Skip to content

Commit

Permalink
Improve the tests (refactoring)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsjf committed Jan 4, 2017
1 parent b83124a commit de84e8b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/testthat/test_query.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,18 @@ test_that("Auxiliary queries", {
expect_identical(nrow(qproperty), 43L)
})

time_range_db <- query_time(db) %>% dplyr::select(start,end)
time_range <- c(format(time_range_db$start[1], '%Y-%m-%d %H:%M:%S'),
format(time_range_db$end[1], '%Y-%m-%d %H:%M:%S'))

time_range_UTC <- as.POSIXct(c(format(time_range_db$start[1], '%Y-%m-%d %H:%M:%S'),
format(time_range_db$end[1], '%Y-%m-%d %H:%M:%S')),
tz = 'UTC')

test_that("Time range", {
time_range_db <- query_time(db) %>% dplyr::select(start,end)
time_range <- c(format(time_range_db$start[1], '%Y-%m-%d %H:%M:%S'),
format(time_range_db$end[1], '%Y-%m-%d %H:%M:%S'))
expect_identical(query_interval(db, "Generator", "Generation", time.range = time_range),
query_interval(db, "Generator", "Generation"))

time_range <- as.POSIXct(c(format(time_range_db$start[1], '%Y-%m-%d %H:%M:%S'),
format(time_range_db$end[1], '%Y-%m-%d %H:%M:%S')),
tz = 'UTC')
expect_identical(query_interval(db, "Generator", "Generation", time.range = time_range),
query_interval(db, "Generator", "Generation")) # test to see if it indeed queries the whole solution
expect_identical(query_interval(db, "Generator", "Generation", time.range = time_range_UTC),
query_interval(db, "Generator", "Generation")) # test to see if the Plexos data is indeed
# parsed under UTC
})
Expand Down

0 comments on commit de84e8b

Please sign in to comment.