Skip to content

Commit

Permalink
Merge pull request #57 from TrevorFrench/cran-tests
Browse files Browse the repository at this point in the history
skipping tests on CRAN as directed by CRAN team
  • Loading branch information
TrevorFrench authored May 28, 2024
2 parents a712376 + d3d03a7 commit 8887471
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cryptotrackr
Type: Package
Title: An Interface to Crypto Data Sources
Version: 1.2.2
Version: 1.2.3
Authors@R: c(
person("Trevor", "French", ,"FrenchTrevor@outlook.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6246-2249"))
Expand Down
13 changes: 9 additions & 4 deletions tests/testthat/test-binance_us.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
test_that('the "binance_us_server_time" function returns a double', {
skip_on_cran()
expect_type(binance_us_server_time(), 'double')
})

test_that('the "binance_us_ping" function returns a "200" status code', {
skip_on_cran()
expect_true(binance_us_ping()$status_code == 200)
})

test_that('the "binance_us_time" function returns a double', {
skip_on_cran()
expect_type(binance_us_server_time(), 'double')
})

test_that('the "binance_us_recent_trades" function returns a dataframe
regardless of symbol casing', {
expect_s3_class(binance_us_recent_trades('LTCBTC', 1000), 'data.frame')
expect_s3_class(binance_us_recent_trades('LtCbTc', 1000), 'data.frame')
expect_s3_class(binance_us_recent_trades('ltcbtc', 1000), 'data.frame')
skip_on_cran()
expect_s3_class(binance_us_recent_trades('LTCBTC', 1000), 'data.frame')
expect_s3_class(binance_us_recent_trades('LtCbTc', 1000), 'data.frame')
expect_s3_class(binance_us_recent_trades('ltcbtc', 1000), 'data.frame')
})

test_that('the "binance_us_recent_trades" function does not return more rows
than the specified limit', {
expect_true(nrow(binance_us_recent_trades('LTCBTC', 10)) <= 10)
skip_on_cran()
expect_true(nrow(binance_us_recent_trades('LTCBTC', 10)) <= 10)
})
9 changes: 9 additions & 0 deletions tests/testthat/test-blockchain_dot_com.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
test_that('the "blockchain_dot_com_symbols" function returns a list', {
skip_on_cran()
expect_type(blockchain_dot_com_symbols(), 'list')
})

test_that('the "blockchain_dot_com_symbol" function returns a list when blank or
with different casing', {
skip_on_cran()
expect_type(blockchain_dot_com_symbol('BTC-USD'), 'list')
expect_type(blockchain_dot_com_symbol('btc-usd'), 'list')
expect_type(blockchain_dot_com_symbol('BtC-uSd'), 'list')
Expand All @@ -12,22 +14,26 @@ test_that('the "blockchain_dot_com_symbol" function returns a list when blank or

test_that('the "blockchain_dot_com_ticker_symbol" function returns a list no
matter the casing', {
skip_on_cran()
expect_type(blockchain_dot_com_ticker_symbol('BTC-USD'), 'list')
expect_type(blockchain_dot_com_ticker_symbol('btc-usd'), 'list')
expect_type(blockchain_dot_com_ticker_symbol('BtC-uSD'), 'list')
})

test_that('the "blockchain_dot_com_ticker_symbol" function returns a data.frame
when no symbol is provided', {
skip_on_cran()
expect_s3_class(blockchain_dot_com_ticker_symbol(''), 'data.frame')
})

test_that('the "blockchain_dot_com_tickers" function returns a data.frame', {
skip_on_cran()
expect_s3_class(blockchain_dot_com_tickers(), 'data.frame')
})

test_that('the "blockchain_dot_com_l2_order_book" function returns a list
containing a bids and an asks data.frame', {
skip_on_cran()
symbol <- 'BTC-USD'
l2_order_book <- blockchain_dot_com_l2_order_book(symbol)
expect_s3_class(l2_order_book$bids, 'data.frame')
Expand All @@ -36,6 +42,7 @@ test_that('the "blockchain_dot_com_l2_order_book" function returns a list

test_that('the "blockchain_dot_com_l2_order_book" function returns a list
containing a bids and an asks data.frame regardless of casing', {
skip_on_cran()
symbol <- 'btc-UsD'
l2_order_book <- blockchain_dot_com_l2_order_book(symbol)
expect_s3_class(l2_order_book$bids, 'data.frame')
Expand All @@ -44,6 +51,7 @@ test_that('the "blockchain_dot_com_l2_order_book" function returns a list

test_that('the "blockchain_dot_com_l3_order_book" function returns a list
containing a bids and an asks data.frame', {
skip_on_cran()
symbol <- 'BTC-USD'
l3_order_book <- blockchain_dot_com_l3_order_book(symbol)
expect_s3_class(l3_order_book$bids, 'data.frame')
Expand All @@ -52,6 +60,7 @@ test_that('the "blockchain_dot_com_l3_order_book" function returns a list

test_that('the "blockchain_dot_com_l3_order_book" function returns a list
containing a bids and an asks data.frame regardless of casing', {
skip_on_cran()
symbol <- 'btc-UsD'
l3_order_book <- blockchain_dot_com_l3_order_book(symbol)
expect_s3_class(l3_order_book$bids, 'data.frame')
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-cex_io.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
test_that('the "cex_io_ticker" function returns a list regardless of casing', {
skip_on_cran()
expect_type(cex_io_ticker('BTC', 'usd'), 'list')
})

test_that('the "cex_io_ticker" function does not return an error regardless of
casing', {
skip_on_cran()
expect_true(is.null(cex_io_ticker('BTC', 'usd')$error))
})

test_that('the "cex_io_currency_limits" function returns a dataframe', {
skip_on_cran()
expect_s3_class(cex_io_currency_limits(), 'data.frame')
})

test_that('the "cex_io_last_price" function does not return an error regardless
of the symbol casing', {
skip_on_cran()
expect_true(is.null(cex_io_last_price('btc', 'usd')$error))
expect_true(is.null(cex_io_last_price('BTC', 'USD')$error))
expect_true(is.null(cex_io_last_price('BtC', 'uSd')$error))
})

test_that('the "cex_io_converter" function does not return a null value
regardless of the symbol casing', {
skip_on_cran()
expect_true(!is.null(cex_io_converter('btc', 'usd', 2.5)))
expect_true(!is.null(cex_io_converter('BTC', 'USD', 2.5)))
expect_true(!is.null(cex_io_converter('BtC', 'uSd', 2.5)))
})

test_that('the "cex_io_ohlcv" function does not return a null value regardless
of the symbol casing', {
skip_on_cran()
expect_type(cex_io_ohlcv('20220927', 'btc', 'usd'), 'list')
expect_type(cex_io_ohlcv('20220927', 'BTC', 'USD'), 'list')
expect_type(cex_io_ohlcv('20220927', 'BtC', 'uSd'), 'list')
})

test_that('the "cex_io_nonce" function returns a double', {
skip_on_cran()
expect_type(cex_io_nonce(), 'double')
})
4 changes: 4 additions & 0 deletions tests/testthat/test-coinbase.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
test_that('the "coinbase_all_currencies" function returns a dataframe', {
skip_on_cran()
expect_s3_class(coinbase_all_currencies(), 'data.frame')
})

test_that('the "coinbase_single_currency" function returns a list whether a
currency is supplied and regardless of symbol casing', {
skip_on_cran()
expect_type(coinbase_single_currency(''), 'list')
expect_type(coinbase_single_currency('btc'), 'list')
expect_type(coinbase_single_currency('bTc'), 'list')
Expand All @@ -12,9 +14,11 @@ test_that('the "coinbase_single_currency" function returns a list whether a

test_that('the "coinbase_single_currency" function will return a "NotFound"
message when applicable', {
skip_on_cran()
expect_true(coinbase_single_currency('MADEUPASSET')$message == "NotFound")
})

test_that('the "coinbase_time" function returns a double', {
skip_on_cran()
expect_type(coinbase_time(), 'double')
})
1 change: 1 addition & 0 deletions tests/testthat/test-coingecko.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test_that('the "coingecko_ping" function returns a list', {
skip_on_cran()
expect_type(coingecko_ping(), 'list')
})
2 changes: 2 additions & 0 deletions tests/testthat/test-coinlist.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
test_that('the "coinlist_symbols" function returns a dataframe', {
skip_on_cran()
expect_s3_class(coinlist_symbols(), 'data.frame')
})

test_that('the "coinlist_time" function returns a double', {
skip_on_cran()
expect_type(coinlist_time(), 'double')
})
5 changes: 5 additions & 0 deletions tests/testthat/test-crypto_dot_com.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
test_that('the "crypto_dot_com_instruments" function returns a dataframe', {
skip_on_cran()
expect_s3_class(crypto_dot_com_instruments(), 'data.frame')
})

test_that('the "crypto_dot_com_get_book" function returns a list with
depth/instrument as specified and a dataframe', {
skip_on_cran()
pair <- "BTC_USDT"
resp <- crypto_dot_com_get_book(pair)
expect_type(resp, 'list')
Expand All @@ -14,6 +16,7 @@ test_that('the "crypto_dot_com_get_book" function returns a list with

test_that('the "crypto_dot_com_get_candlestick" function returns a list with
interval/instrument as specified and a dataframe', {
skip_on_cran()
pair <- "BTC_USDT"
resp <- crypto_dot_com_get_candlestick(pair)
expect_type(resp, 'list')
Expand All @@ -24,6 +27,7 @@ test_that('the "crypto_dot_com_get_candlestick" function returns a list with

test_that('the "crypto_dot_com_get_ticker" function returns a dataframe wih
information about the specified instrument', {
skip_on_cran()
pair <- "BTC_USDT"
resp <- crypto_dot_com_get_ticker(pair)
expect_s3_class(resp, 'data.frame')
Expand All @@ -32,6 +36,7 @@ test_that('the "crypto_dot_com_get_ticker" function returns a dataframe wih

test_that('the "crypto_dot_com_get_trades" function returns a dataframe wih
information about the specified instrument', {
skip_on_cran()
pair <- "BTC_USDT"
resp <- crypto_dot_com_get_trades(pair)
expect_s3_class(resp, 'data.frame')
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-gemini.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
test_that('the "gemini_symbols" function returns a character vector', {
skip_on_cran()
expect_type(gemini_symbols(), 'character')
})

test_that('the "gemini_price_feed" function returns a dataframe', {
skip_on_cran()
expect_s3_class(gemini_price_feed(), 'data.frame')
})
1 change: 1 addition & 0 deletions tests/testthat/test-huobi.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test_that('the "huobi_candles" function returns a dataframe', {
skip_on_cran()
expect_s3_class(huobi_candles('1day', '200', 'btcusdt'), 'data.frame')
})
5 changes: 5 additions & 0 deletions tests/testthat/test-kraken.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
test_that('the "kraken_server_time" function returns unixtime as an integer and
rfc1123 as a character', {
skip_on_cran()
expect_type(kraken_server_time()$unixtime, 'integer')
expect_type(kraken_server_time()$rfc1123, 'character')
})

test_that('the "kraken_server_time" function returns status as a character and
timestamp as a character', {
skip_on_cran()
expect_type(kraken_server_status()$status, 'character')
expect_type(kraken_server_status()$timestamp, 'character')
})

test_that('the "kraken_asset_info" function returns a list', {
skip_on_cran()
expect_type(kraken_asset_info(), 'list')
expect_type(kraken_asset_info("ETH,BTC"), 'list')
expect_type(kraken_asset_info(aclass = "currency"), 'list')
})

test_that('the "kraken_asset_pairs" function returns a list', {
skip_on_cran()
expect_type(kraken_asset_pairs(), 'list')
})

test_that('the "kraken_ticker_info" function returns a list', {
skip_on_cran()
expect_type(kraken_ticker_info("ETHUSD"), 'list')
})
2 changes: 2 additions & 0 deletions tests/testthat/test-kucoin.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
test_that('the "kucoin_time" function returns a character', {
skip_on_cran()
expect_type(kucoin_time(), 'character')
})

test_that('the "kucoin_symbols_list" function returns a dataframe', {
skip_on_cran()
expect_s3_class(kucoin_symbols_list('btc'), 'data.frame')
})
3 changes: 3 additions & 0 deletions tests/testthat/test-magic_eden.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
test_that('the "magic_eden_collection_stats" function returns a list with a
"symbol" element that matches the provided symbol', {
skip_on_cran()
symbol <- "gothic_degens"
resp <- magic_eden_collection_stats(symbol)
expect_type(resp, 'list')
expect_true(resp$symbol == symbol)
})

test_that('the "magic_eden_tokens_owned" function returns a dataframe', {
skip_on_cran()
wallet <- "72tXz6jhGVPFE8ZfAQocJPJU3HgxsdrRqKZoUdWUhs7o"
resp <- magic_eden_tokens_owned(wallet)
expect_s3_class(resp, 'data.frame')
})

test_that('the "magic_eden_transactions" function returns a dataframe', {
skip_on_cran()
wallet <- "72tXz6jhGVPFE8ZfAQocJPJU3HgxsdrRqKZoUdWUhs7o"
resp <- magic_eden_transactions(wallet)
expect_s3_class(resp, 'data.frame')
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-okcoin.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that('the "okcocin_trading_pairs" function returns a dataframe', {
skip_on_cran()
expect_s3_class(okcoin_trading_pairs(), 'data.frame')
})

Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-solana.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that('the "solana_get_signature_for_address" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
address <- "Vote111111111111111111111111111111111111111"
data <- tryCatch(
Expand All @@ -10,6 +11,7 @@ test_that('the "solana_get_signature_for_address" function returns a list', {
})

test_that('the "solana_get_account_info" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
pubkey <- "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"
data <- tryCatch(
Expand All @@ -21,6 +23,7 @@ test_that('the "solana_get_account_info" function returns a list', {
})

test_that('the "solana_get_account_info" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_block_height(url),
Expand All @@ -31,6 +34,7 @@ test_that('the "solana_get_account_info" function returns a list', {
})

test_that('the "solana_get_health" function returns a character', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_health(url),
Expand All @@ -41,6 +45,7 @@ test_that('the "solana_get_health" function returns a character', {
})

test_that('the "solana_get_version" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_version(url),
Expand All @@ -51,6 +56,7 @@ test_that('the "solana_get_version" function returns a list', {
})

test_that('the "solana_get_supply" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_supply(url),
Expand All @@ -61,6 +67,7 @@ test_that('the "solana_get_supply" function returns a list', {
})

test_that('the "solana_get_identity" function returns a character', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_identity(url),
Expand All @@ -71,6 +78,7 @@ test_that('the "solana_get_identity" function returns a character', {
})

test_that('the "solana_get_inflation_rate" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_inflation_rate(url),
Expand All @@ -81,6 +89,7 @@ test_that('the "solana_get_inflation_rate" function returns a list', {
})

test_that('the "solana_get_genesis_hash" function returns a character', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_genesis_hash(url),
Expand All @@ -92,6 +101,7 @@ test_that('the "solana_get_genesis_hash" function returns a character', {

test_that('the "solana_get_slot" function returns an integer and the
"solana_get_block" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
slot <- tryCatch(
solana_get_slot(url),
Expand All @@ -108,6 +118,7 @@ test_that('the "solana_get_slot" function returns an integer and the
})

test_that('the "solana_get_recent_prioritization_fees" function returns a list', {
skip_on_cran()
url <- "https://api.devnet.solana.com"
data <- tryCatch(
solana_get_recent_prioritization_fees(url),
Expand Down

0 comments on commit 8887471

Please sign in to comment.