test_that("argentum_list_layers handles valid input", {
# Mock argentum_list_organizations and argentum_get_capabilities
data.frame(Name = "Test Org", WFS_URL = "http://test.com/wfs", stringsAsFactors = FALSE))
test_that("argentum_list_layers handles WMS URL", {
data.frame(Name = "Test Org", WFS_URL = "http://test.com/wms?service=WMS", stringsAsFactors = FALSE))
expect_message(argentum_list_layers("Test Org"), "WMS URL detected. Attempting to construct WFS URL...")
test_that("argentum_list_layers handles invalid organization", {
mockery::stub(argentum_list_layers, "argentum_list_organizations", data.frame(Name = character(0), WFS_URL = character(0), stringsAsFactors = FALSE))
expect_error(argentum_list_layers("Invalid Org"), "Organization not found.")
test_that("argentum_list_layers handles empty layer list", {
expect_warning(result <- argentum_list_layers("Test Org"), "No WFS layers found for the specified organization.")

"WMS URL detected. Attempting to construct WFS URL..."
"argentum_list_layers handles empty layer list"
"No WFS layers found for the specified organization."

argentum_list_layers handles empty layer list

test_that("argentum_list_organizations returns correct structure", {
# Mock readr::read_delim to return test data
data.frame(Category = "Test", Organization = "Org", WMS_URL = "http://wms.test", WFS_URL = "http://wfs.test", stringsAsFactors = FALSE))
expect_true(all(c("Name", "WMS_URL", "WFS_URL") %in% names(result)))
test_that("argentum_list_organizations handles empty WFS_URL", {
data.frame(Category = "Test", Organization = "Org", WMS_URL = "http://wms.test", WFS_URL = "", stringsAsFactors = FALSE))
data.frame(Category = "Test", Organization = "Org", WMS_URL = "[WMS] http://wms.test ", WFS_URL = "(WFS) http://wfs.test ", stringsAsFactors = FALSE))
test_that("argentum_list_organizations handles all sources failing", {
expect_error(argentum_list_organizations(), "Failed to retrieve organization data from all sources.")

"argentum_list_organizations handles all sources failing"
"Failed to retrieve organization data from all sources."