-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
complete splits endpoint implementation
- Loading branch information
1 parent
45d7ffa
commit 62036b7
Showing
2 changed files
with
81 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,66 @@ | ||
use marketstack::api::common::SortOrder; | ||
use chrono::NaiveDate; | ||
|
||
use marketstack::api::{splits, AsyncQuery, Query}; | ||
use marketstack::{AsyncMarketstack, EodData, Marketstack}; | ||
use marketstack::{AsyncMarketstack, Marketstack, SplitsData}; | ||
|
||
mod setup; | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_splits() { | ||
let api_key = setup::setup_key(); | ||
let client = Marketstack::new_insecure("api.marketstack.com", api_key).unwrap(); | ||
|
||
let endpoint = splits::Splits::builder() | ||
.symbol("AAPL") | ||
.limit(3) | ||
.unwrap() | ||
.build() | ||
.unwrap(); | ||
let splits_result: SplitsData = endpoint.query(&client).unwrap(); | ||
|
||
assert_eq!(splits_result.pagination.limit, 3); | ||
assert_eq!(splits_result.pagination.offset, 0); | ||
|
||
assert_eq!(splits_result.data.len(), 3); | ||
} | ||
|
||
#[tokio::test] | ||
#[ignore] | ||
async fn test_async_splits() { | ||
let api_key = setup::setup_key(); | ||
let client = AsyncMarketstack::new_insecure("api.marketstack.com", api_key) | ||
.await | ||
.unwrap(); | ||
|
||
let endpoint = splits::Splits::builder() | ||
.limit(3) | ||
.unwrap() | ||
.symbol("AAPL") | ||
.build() | ||
.unwrap(); | ||
let eod_result: SplitsData = endpoint.query_async(&client).await.unwrap(); | ||
|
||
assert_eq!(eod_result.pagination.limit, 3); | ||
assert_eq!(eod_result.pagination.offset, 0); | ||
|
||
assert_eq!(eod_result.data.len(), 3); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_splits_date() { | ||
let api_key = setup::setup_key(); | ||
let client = Marketstack::new_insecure("api.marketstack.com", api_key).unwrap(); | ||
|
||
let endpoint = splits::Splits::builder() | ||
.symbol("AAPL") | ||
.date_from(NaiveDate::from_ymd_opt(2020, 8, 29).unwrap()) | ||
.date_to(NaiveDate::from_ymd_opt(2020, 9, 2).unwrap()) | ||
.build() | ||
.unwrap(); | ||
let splits_result: SplitsData = endpoint.query(&client).unwrap(); | ||
|
||
assert_eq!(splits_result.data.len(), 1); | ||
assert_eq!(splits_result.data[0].split_factor, 4.0); | ||
} |