Skip to content

Commit

Permalink
fixed test bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
CHRISCARLON committed Aug 13, 2024
1 parent fc2a58e commit cc5ed22
Showing 1 changed file with 50 additions and 53 deletions.
103 changes: 50 additions & 53 deletions tests/exqs_tests.rs
Original file line number Diff line number Diff line change
@@ -1,80 +1,77 @@
use exqs::remote_file_functions::{
analyze_excel_formatting, display_remote_basic_info, excel_quick_view, fetch_remote_file,
analyze_excel_formatting, display_remote_basic_info,
display_remote_basic_info_specify_header_idx, excel_quick_view, fetch_remote_file,
};

#[test]
fn test_excel_quick_view() {
// Test URL for a valid remote Excel file
let url = "https://datamillnorth.org/download/2o13g/c476394e-8294-4c15-b1ff-44d32e6809c2/06.2024.%20.xlsx";
fn test_file_fetch() {
let url = "https://data.london.gov.uk/download/licensed-vehicles-numbers-borough/45c47aba-682d-4be4-b62a-42215203c2ad/Copy%20of%20vehicles-licensed-borough%20%281%29.xls";

// First, fetch the file
// Fetch the file
let fetch_result = fetch_remote_file(url);

// Assert that the fetch was successful
assert!(fetch_result.is_ok(), "Failed to fetch the remote file");

// If fetch was successful, proceed to quick view
// If the fetch was successful, we can add more specific checks
if let Ok(content) = fetch_result {
// Call excel_quick_view and check if it's Ok - check no errors are returned.
// This is only a basic test to begin with - needs to be made better in the future.
let quick_view_result = excel_quick_view(content);
assert!(
quick_view_result.is_ok(),
"Failed to perform quick view of Excel file"
);
// Check that we actually got some data
assert!(!content.is_empty(), "Fetched file content is empty");
}
}

#[test]
pub fn test_analyze_excel_formatting() {
// Test URL for a valid remote Excel file
let url = "https://data.london.gov.uk/download/mopac-grants-awarded/5ce18260-f2bb-4c80-8669-df06ab041445/MOPAC%20Q4%20Upload.xlsx";
fn test_display_remote_basic_info() {
let url = "https://data.london.gov.uk/download/ratio-house-prices-earnings-borough/122ea18a-cb44-466e-a314-e0c62a32529e/ratio-house-price-earnings-residence-based.xlsx";

// First, fetch the file
let fetch_result = fetch_remote_file(url);
assert!(fetch_result.is_ok(), "Failed to fetch the remote file");
// Fetch the file and handle the Result
let content = fetch_remote_file(url).expect("Failed to fetch remote file");

// If fetch was successful, proceed to analyze formatting
if let Ok(content) = fetch_result {
let analysis_result = analyze_excel_formatting(content);
// Assert that the analysis was successful
assert!(
analysis_result.is_ok(),
"Failed to analyze Excel formatting"
);
}
// Now pass the content
let result = display_remote_basic_info(content);

assert!(result.is_ok());
// Add more specific assertions based on the expected output
}

#[test]
fn test_display_remote_basic_info() {
// Test URL for a valid remote Excel file
let url = "https://datamillnorth.org/download/2o13g/c476394e-8294-4c15-b1ff-44d32e6809c2/06.2024.%20.xlsx";
fn test_analyze_excel_formatting() {
let url = "https://data.london.gov.uk/download/unemployment-rate-region/8a29ec0c-9de3-4777-832f-49ef8c2b4d14/unemployment-region.xlsx";

// First, fetch the file
let fetch_result = fetch_remote_file(url);
assert!(fetch_result.is_ok(), "Failed to fetch the remote file");
// Fetch the file and handle the Result
let content = fetch_remote_file(url).expect("Failed to fetch remote file");

// If fetch was successful, proceed to display basic info
if let Ok(content) = fetch_result {
let display_result = display_remote_basic_info(content);
assert!(
display_result.is_ok(),
"Failed to display basic info for the fetched file"
);
}
// Now pass the content
let result = analyze_excel_formatting(content);

assert!(result.is_ok());
// Add more specific assertions based on the expected output
}

#[test]
fn test_file_fetch() {
let url = "https://datamillnorth.org/download/2o13g/c476394e-8294-4c15-b1ff-44d32e6809c2/06.2024.%20.xlsx";
fn test_excel_quick_view() {
let url = "https://data.london.gov.uk/download/number-bicycle-hires/ac29363e-e0cb-47cc-a97a-e216d900a6b0/tfl-daily-cycle-hires.xlsx";

// Fetch the file
let fetch_result = fetch_remote_file(url);
// Fetch the file and handle the Result
let content = fetch_remote_file(url).expect("Failed to fetch remote file");

// Assert that the fetch was successful
assert!(fetch_result.is_ok(), "Failed to fetch the remote file");
// Now pass the content
let result = excel_quick_view(content);

// If the fetch was successful, we can add more specific checks
if let Ok(content) = fetch_result {
// Check that we actually got some data
assert!(!content.is_empty(), "Fetched file content is empty");
}
assert!(result.is_ok());
// Add more specific assertions based on the expected output
}

#[test]
fn test_display_remote_basic_info_specify_header_idx() {
let url = "https://data.london.gov.uk/download/number-bicycle-hires/ac29363e-e0cb-47cc-a97a-e216d900a6b0/tfl-daily-cycle-hires.xlsx";

// Fetch the file and handle the Result
let content = fetch_remote_file(url).expect("Failed to fetch remote file");

// Now pass the content
let result = display_remote_basic_info_specify_header_idx(content, 3);

assert!(result.is_ok());
// Add more specific assertions based on the expected output
}

0 comments on commit cc5ed22

Please sign in to comment.