diff --git a/test/test_analysisAssim.py b/test/test_analysisAssim.py new file mode 100644 index 0000000..54ca0e5 --- /dev/null +++ b/test/test_analysisAssim.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 5 # Set to 5 for the analysis_assim folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimExtend.py b/test/test_analysisAssimExtend.py new file mode 100644 index 0000000..90f099a --- /dev/null +++ b/test/test_analysisAssimExtend.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_extend(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 6 # Set to 6 for the analysis_assim_extend folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim_extend folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend/nwm.t00z.analysis_assim_extend.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend/nwm.t00z.analysis_assim_extend.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend/nwm.t08z.analysis_assim_extend.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend/nwm.t08z.analysis_assim_extend.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend/nwm.t00z.analysis_assim_extend.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend/nwm.t00z.analysis_assim_extend.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend/nwm.t08z.analysis_assim_extend.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend/nwm.t08z.analysis_assim_extend.channel_rt.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimExtendNoDa.py b/test/test_analysisAssimExtendNoDa.py new file mode 100644 index 0000000..4f30279 --- /dev/null +++ b/test/test_analysisAssimExtendNoDa.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_extend_no_da(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 7 # Set to 7 for the assim_extend_no_da folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the assim_extend_no_da folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend_no_da/nwm.t00z.analysis_assim_extend_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend_no_da/nwm.t00z.analysis_assim_extend_no_da.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend_no_da/nwm.t08z.analysis_assim_extend_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_extend_no_da/nwm.t08z.analysis_assim_extend_no_da.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend_no_da/nwm.t00z.analysis_assim_extend_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend_no_da/nwm.t00z.analysis_assim_extend_no_da.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend_no_da/nwm.t08z.analysis_assim_extend_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_extend_no_da/nwm.t08z.analysis_assim_extend_no_da.channel_rt.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimHawaii.py b/test/test_analysisAssimHawaii.py new file mode 100644 index 0000000..e858083 --- /dev/null +++ b/test/test_analysisAssimHawaii.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_hawaii(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 2 + runinput = 5 # Set to 5 for the analysis_assim_hawaii folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim_hawaii folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t00z.analysis_assim.channel_rt.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim/nwm.t08z.analysis_assim.channel_rt.tm018.hawaii.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimHawaiiNoDa.py b/test/test_analysisAssimHawaiiNoDa.py new file mode 100644 index 0000000..0bab2b6 --- /dev/null +++ b/test/test_analysisAssimHawaiiNoDa.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_hawaii_no_da(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 2 + runinput = 10 # Set to 10 for the analysis_assim_hawaii_no_da folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim_hawaii_no_da folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm018.hawaii.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimNoDa.py b/test/test_analysisAssimNoDa.py new file mode 100644 index 0000000..afb623b --- /dev/null +++ b/test/test_analysisAssimNoDa.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_no_da(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 10 # Set to 5 for the analysis_assim_no_da folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim_no_da folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimPuertorico.py b/test/test_analysisAssimPuertorico.py new file mode 100644 index 0000000..e0b62ae --- /dev/null +++ b/test/test_analysisAssimPuertorico.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_puertorico(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 3 + runinput = 5 # Set to 5 for the analysis_assim_puertorico folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim_puertorico folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico/nwm.t00z.analysis_assim.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico/nwm.t00z.analysis_assim.channel_rt.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico/nwm.t08z.analysis_assim.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico/nwm.t08z.analysis_assim.channel_rt.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico/nwm.t00z.analysis_assim.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico/nwm.t00z.analysis_assim.channel_rt.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico/nwm.t08z.analysis_assim.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico/nwm.t08z.analysis_assim.channel_rt.tm018.puertorico.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_analysisAssimPuertoricoNoDa.py b/test/test_analysisAssimPuertoricoNoDa.py new file mode 100644 index 0000000..e2f93f5 --- /dev/null +++ b/test/test_analysisAssimPuertoricoNoDa.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim_puertorico_no_da(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 3 + runinput = 10 # Set to 10 for the analysis_assim_puertorico_no_da folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim_puertorico_no_da folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/analysis_assim_puertorico_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico_no_da/nwm.t00z.analysis_assim_no_da.channel_rt.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/analysis_assim_puertorico_no_da/nwm.t08z.analysis_assim_no_da.channel_rt.tm018.puertorico.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_cases.py b/test/test_cases.py index 3b464f7..221be67 100644 --- a/test/test_cases.py +++ b/test/test_cases.py @@ -163,10 +163,11 @@ def test_selecturlbase(): "short_range", "medium_range", "long_range_mem7", - "medium_range_no_da_mem6" + "medium_range_no_da_mem6", ] import requests + def is_valid_url(url): try: response = requests.head(url) @@ -194,14 +195,16 @@ def test_create_file_list(runinput, varinput, geoinput, meminput, start_date, en assert all(isinstance(file_name, str) for file_name in file_list) for url in file_list: # assert is_valid_url(url), f"Invalid URL: {url}" - assert any(substring in url for substring in valid_folder_names), f"No valid folder name found in URL: {url}" - + assert any( + substring in url for substring in valid_folder_names + ), f"No valid folder name found in URL: {url}" # Check if all base URLs exist in the predefined list for url in file_list: - assert any(url.startswith(base_url) for base_url in valid_base_urls), f"Invalid base URL in generated URL: {url}" - + assert any( + url.startswith(base_url) for base_url in valid_base_urls + ), f"Invalid base URL in generated URL: {url}" if __name__ == "__main__": - pytest.main() \ No newline at end of file + pytest.main() diff --git a/test/test_forcingAnalysisAssim.py b/test/test_forcingAnalysisAssim.py new file mode 100644 index 0000000..536f903 --- /dev/null +++ b/test/test_forcingAnalysisAssim.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_analysis_assim(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 1 + runinput = 5 # Set to 5 for the forcing_analysis_assim folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_analysis_assim folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim/nwm.t00z.analysis_assim.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim/nwm.t00z.analysis_assim.forcing.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim/nwm.t08z.analysis_assim.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim/nwm.t08z.analysis_assim.forcing.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim/nwm.t00z.analysis_assim.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim/nwm.t00z.analysis_assim.forcing.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim/nwm.t08z.analysis_assim.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim/nwm.t08z.analysis_assim.forcing.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingAnalysisAssimExtend.py b/test/test_forcingAnalysisAssimExtend.py new file mode 100644 index 0000000..1576f28 --- /dev/null +++ b/test/test_forcingAnalysisAssimExtend.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_analysis_assim_extend(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 1 + runinput = 6 # Set to 6 for the forcing_analysis_assim_extend folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_analysis_assim_extend folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_extend/nwm.t00z.analysis_assim_extend.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_extend/nwm.t00z.analysis_assim_extend.forcing.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_extend/nwm.t08z.analysis_assim_extend.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_extend/nwm.t08z.analysis_assim_extend.forcing.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_extend/nwm.t00z.analysis_assim_extend.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_extend/nwm.t00z.analysis_assim_extend.forcing.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_extend/nwm.t08z.analysis_assim_extend.forcing.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_extend/nwm.t08z.analysis_assim_extend.forcing.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingAnalysisAssimHawaii.py b/test/test_forcingAnalysisAssimHawaii.py new file mode 100644 index 0000000..4584975 --- /dev/null +++ b/test/test_forcingAnalysisAssimHawaii.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_analysis_assim_hawaii(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 2 + runinput = 5 # Set to 5 for the forcing_analysis_assim_hawaii folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_analysis_assim_hawaii folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_hawaii/nwm.t00z.analysis_assim.forcing.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_hawaii/nwm.t00z.analysis_assim.forcing.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_hawaii/nwm.t08z.analysis_assim.forcing.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_hawaii/nwm.t08z.analysis_assim.forcing.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_hawaii/nwm.t00z.analysis_assim.forcing.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_hawaii/nwm.t00z.analysis_assim.forcing.tm018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_hawaii/nwm.t08z.analysis_assim.forcing.tm001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_hawaii/nwm.t08z.analysis_assim.forcing.tm018.hawaii.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingAnalysisAssimPuertorico.py b/test/test_forcingAnalysisAssimPuertorico.py new file mode 100644 index 0000000..f104fb7 --- /dev/null +++ b/test/test_forcingAnalysisAssimPuertorico.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_analysis_assim_puertorico(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 3 + runinput = 5 # Set to 5 for the forcing_analysis_assim_puertorico folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_analysis_assim_puertorico folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_puertorico/nwm.t00z.analysis_assim.forcing.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_puertorico/nwm.t00z.analysis_assim.forcing.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_puertorico/nwm.t08z.analysis_assim.forcing.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_analysis_assim_puertorico/nwm.t08z.analysis_assim.forcing.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_puertorico/nwm.t00z.analysis_assim.forcing.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_puertorico/nwm.t00z.analysis_assim.forcing.tm018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_puertorico/nwm.t08z.analysis_assim.forcing.tm001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_analysis_assim_puertorico/nwm.t08z.analysis_assim.forcing.tm018.puertorico.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingMediumRange.py b/test/test_forcingMediumRange.py new file mode 100644 index 0000000..b985d2f --- /dev/null +++ b/test/test_forcingMediumRange.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_medium_range(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 1 + runinput = 2 # Set to 2 for the forcing_medium_range folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_medium_range folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_medium_range_mem1/nwm.t00z.medium_range.forcing_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_medium_range_mem1/nwm.t00z.medium_range.forcing_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_medium_range_mem1/nwm.t08z.medium_range.forcing_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_medium_range_mem1/nwm.t08z.medium_range.forcing_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_medium_range_mem1/nwm.t00z.medium_range.forcing_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_medium_range_mem1/nwm.t00z.medium_range.forcing_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_medium_range_mem1/nwm.t08z.medium_range.forcing_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_medium_range_mem1/nwm.t08z.medium_range.forcing_1.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingShortRange.py b/test/test_forcingShortRange.py new file mode 100644 index 0000000..d089176 --- /dev/null +++ b/test/test_forcingShortRange.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_short_range(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 10 + geoinput = 1 + runinput = 1 # Set to 1 for the forcing_short_range folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_short_range folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t00z.short_range.variable_error.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t00z.short_range.variable_error.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t08z.short_range.variable_error.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t08z.short_range.variable_error.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t00z.short_range.variable_error.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t00z.short_range.variable_error.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t08z.short_range.variable_error.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t08z.short_range.variable_error.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingShortRangeAssimHawaii.py b/test/test_forcingShortRangeAssimHawaii.py new file mode 100644 index 0000000..9a1ee20 --- /dev/null +++ b/test/test_forcingShortRangeAssimHawaii.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_short_range_assim_hawaii(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 2 + runinput = 1 # Set to 1 for the forcing_short_range_assim_hawaii folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_short_range_assim_hawaii folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_hawaii/nwm.t00z.short_range.forcing.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_hawaii/nwm.t00z.short_range.forcing.f018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_hawaii/nwm.t08z.short_range.forcing.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_hawaii/nwm.t08z.short_range.forcing.f018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_hawaii/nwm.t00z.short_range.forcing.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_hawaii/nwm.t00z.short_range.forcing.f018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_hawaii/nwm.t08z.short_range.forcing.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_hawaii/nwm.t08z.short_range.forcing.f018.hawaii.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_forcingShortRangeAssimPuertorico.py b/test/test_forcingShortRangeAssimPuertorico.py new file mode 100644 index 0000000..91bdd4b --- /dev/null +++ b/test/test_forcingShortRangeAssimPuertorico.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_forcing_short_range_assim_puerorico(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 5 + geoinput = 3 + runinput = 1 # Set to 1 for the forcing_short_range_assim_puerorico folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the forcing_short_range_assim_puerorico folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_puertorico/nwm.t00z.short_range.forcing.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_puertorico/nwm.t00z.short_range.forcing.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_puertorico/nwm.t08z.short_range.forcing.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/forcing_short_range_puertorico/nwm.t08z.short_range.forcing.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_puertorico/nwm.t00z.short_range.forcing.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_puertorico/nwm.t00z.short_range.forcing.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_puertorico/nwm.t08z.short_range.forcing.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/forcing_short_range_puertorico/nwm.t08z.short_range.forcing.f018.puertorico.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_longRangeMem1.py b/test/test_longRangeMem1.py new file mode 100644 index 0000000..d5bd923 --- /dev/null +++ b/test/test_longRangeMem1.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_long_range_mem1(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 4 # Set to 4 for the long_range_mem1 folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the long_range_mem1 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem1/nwm.t00z.long_range.channel_rt_1.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem1/nwm.t00z.long_range.channel_rt_1.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem1/nwm.t08z.long_range.channel_rt_1.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem1/nwm.t08z.long_range.channel_rt_1.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem1/nwm.t00z.long_range.channel_rt_1.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem1/nwm.t00z.long_range.channel_rt_1.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem1/nwm.t08z.long_range.channel_rt_1.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem1/nwm.t08z.long_range.channel_rt_1.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_longRangeMem2.py b/test/test_longRangeMem2.py new file mode 100644 index 0000000..6d75a95 --- /dev/null +++ b/test/test_longRangeMem2.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_long_range_mem2(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 4 # Set to 4 for the long_range_mem1 folder + urlbaseinput = 2 + meminput = 2 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the long_range_mem1 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem2/nwm.t00z.long_range.channel_rt_2.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem2/nwm.t00z.long_range.channel_rt_2.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem2/nwm.t08z.long_range.channel_rt_2.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem2/nwm.t08z.long_range.channel_rt_2.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem2/nwm.t00z.long_range.channel_rt_2.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem2/nwm.t00z.long_range.channel_rt_2.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem2/nwm.t08z.long_range.channel_rt_2.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem2/nwm.t08z.long_range.channel_rt_2.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_longRangeMem3.py b/test/test_longRangeMem3.py new file mode 100644 index 0000000..6553050 --- /dev/null +++ b/test/test_longRangeMem3.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_long_range_mem3(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 4 # Set to 4 for the long_range_mem3 folder + urlbaseinput = 2 + meminput = 3 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the long_range_mem3 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem3/nwm.t00z.long_range.channel_rt_3.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem3/nwm.t00z.long_range.channel_rt_3.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem3/nwm.t08z.long_range.channel_rt_3.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem3/nwm.t08z.long_range.channel_rt_3.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem3/nwm.t00z.long_range.channel_rt_3.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem3/nwm.t00z.long_range.channel_rt_3.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem3/nwm.t08z.long_range.channel_rt_3.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem3/nwm.t08z.long_range.channel_rt_3.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_longRangeMem4.py b/test/test_longRangeMem4.py new file mode 100644 index 0000000..818ca17 --- /dev/null +++ b/test/test_longRangeMem4.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_long_range_mem4(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 4 # Set to 4 for the long_range_mem4 folder + urlbaseinput = 2 + meminput = 4 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the long_range_mem4 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem4/nwm.t00z.long_range.channel_rt_4.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem4/nwm.t00z.long_range.channel_rt_4.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem4/nwm.t08z.long_range.channel_rt_4.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/long_range_mem4/nwm.t08z.long_range.channel_rt_4.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem4/nwm.t00z.long_range.channel_rt_4.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem4/nwm.t00z.long_range.channel_rt_4.tm018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem4/nwm.t08z.long_range.channel_rt_4.tm001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/long_range_mem4/nwm.t08z.long_range.channel_rt_4.tm018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMem1.py b/test/test_mediumRangeMem1.py new file mode 100644 index 0000000..ad5088c --- /dev/null +++ b/test/test_mediumRangeMem1.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_mem1(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_mem1 folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_mem1 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem1/nwm.t00z.medium_range.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem1/nwm.t00z.medium_range.channel_rt_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem1/nwm.t08z.medium_range.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem1/nwm.t08z.medium_range.channel_rt_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem1/nwm.t00z.medium_range.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem1/nwm.t00z.medium_range.channel_rt_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem1/nwm.t08z.medium_range.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem1/nwm.t08z.medium_range.channel_rt_1.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMem2.py b/test/test_mediumRangeMem2.py new file mode 100644 index 0000000..1630840 --- /dev/null +++ b/test/test_mediumRangeMem2.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_mem2(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_mem2 folder + urlbaseinput = 2 + meminput = 2 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_mem2 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem2/nwm.t00z.medium_range.channel_rt_2.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem2/nwm.t00z.medium_range.channel_rt_2.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem2/nwm.t08z.medium_range.channel_rt_2.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem2/nwm.t08z.medium_range.channel_rt_2.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem2/nwm.t00z.medium_range.channel_rt_2.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem2/nwm.t00z.medium_range.channel_rt_2.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem2/nwm.t08z.medium_range.channel_rt_2.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem2/nwm.t08z.medium_range.channel_rt_2.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMem3.py b/test/test_mediumRangeMem3.py new file mode 100644 index 0000000..7641740 --- /dev/null +++ b/test/test_mediumRangeMem3.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_mem3(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_mem3 folder + urlbaseinput = 2 + meminput = 3 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_mem3 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem3/nwm.t00z.medium_range.channel_rt_3.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem3/nwm.t00z.medium_range.channel_rt_3.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem3/nwm.t08z.medium_range.channel_rt_3.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem3/nwm.t08z.medium_range.channel_rt_3.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem3/nwm.t00z.medium_range.channel_rt_3.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem3/nwm.t00z.medium_range.channel_rt_3.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem3/nwm.t08z.medium_range.channel_rt_3.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem3/nwm.t08z.medium_range.channel_rt_3.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMem4.py b/test/test_mediumRangeMem4.py new file mode 100644 index 0000000..5e579af --- /dev/null +++ b/test/test_mediumRangeMem4.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_mem4(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_mem4 folder + urlbaseinput = 2 + meminput = 4 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_mem4 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMem5.py b/test/test_mediumRangeMem5.py new file mode 100644 index 0000000..246cfd6 --- /dev/null +++ b/test/test_mediumRangeMem5.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_mem5(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_mem5 folder + urlbaseinput = 2 + meminput = 5 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_mem5 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem5/nwm.t00z.medium_range.channel_rt_5.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem5/nwm.t00z.medium_range.channel_rt_5.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem5/nwm.t08z.medium_range.channel_rt_5.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem5/nwm.t08z.medium_range.channel_rt_5.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem5/nwm.t00z.medium_range.channel_rt_5.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem5/nwm.t00z.medium_range.channel_rt_5.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem5/nwm.t08z.medium_range.channel_rt_5.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem5/nwm.t08z.medium_range.channel_rt_5.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMem6.py b/test/test_mediumRangeMem6.py new file mode 100644 index 0000000..cb4f2b9 --- /dev/null +++ b/test/test_mediumRangeMem6.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_mem6(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_mem6 folder + urlbaseinput = 2 + meminput = 6 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_mem6 folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem6/nwm.t00z.medium_range.channel_rt_6.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem6/nwm.t00z.medium_range.channel_rt_6.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem6/nwm.t08z.medium_range.channel_rt_6.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem6/nwm.t08z.medium_range.channel_rt_6.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem6/nwm.t00z.medium_range.channel_rt_6.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem6/nwm.t00z.medium_range.channel_rt_6.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem6/nwm.t08z.medium_range.channel_rt_6.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem6/nwm.t08z.medium_range.channel_rt_6.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeMemNoDa.py b/test/test_mediumRangeMemNoDa.py new file mode 100644 index 0000000..1f6e388 --- /dev/null +++ b/test/test_mediumRangeMemNoDa.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_medium_range_no_da(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 2 # Set to 2 for the medium_range_no_da folder + urlbaseinput = 2 + meminput = 4 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the medium_range_no_da folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t00z.medium_range.channel_rt_4.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_mem4/nwm.t08z.medium_range.channel_rt_4.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_mediumRangeNoDa.py b/test/test_mediumRangeNoDa.py new file mode 100644 index 0000000..f2410b5 --- /dev/null +++ b/test/test_mediumRangeNoDa.py @@ -0,0 +1,60 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_analysis_assim(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 3 # Set to 5 for the analysis_assim folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the analysis_assim folder + # Define the expected URLs or patterns for the analysis_assim folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_no_da_mem1/nwm.t00z.medium_range_no_da.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_no_da_mem1/nwm.t00z.medium_range_no_da.channel_rt_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_no_da_mem1/nwm.t08z.medium_range_no_da.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/medium_range_no_da_mem1/nwm.t08z.medium_range_no_da.channel_rt_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_no_da_mem1/nwm.t00z.medium_range_no_da.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_no_da_mem1/nwm.t00z.medium_range_no_da.channel_rt_1.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_no_da_mem1/nwm.t08z.medium_range_no_da.channel_rt_1.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/medium_range_no_da_mem1/nwm.t08z.medium_range_no_da.channel_rt_1.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_shortRange.py b/test/test_shortRange.py new file mode 100644 index 0000000..13a3cc6 --- /dev/null +++ b/test/test_shortRange.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_short_range(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 1 + runinput = 1 # Set to 1 for the short_range folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the short_range folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t00z.short_range.channel_rt.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t00z.short_range.channel_rt.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t08z.short_range.channel_rt.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t08z.short_range.channel_rt.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t00z.short_range.channel_rt.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t00z.short_range.channel_rt.f018.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t08z.short_range.channel_rt.f001.conus.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t08z.short_range.channel_rt.f018.conus.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_shortRangeAssimHawaii.py b/test/test_shortRangeAssimHawaii.py new file mode 100644 index 0000000..f471d89 --- /dev/null +++ b/test/test_shortRangeAssimHawaii.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_short_range_assim_hawaii(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 2 + runinput = 1 # Set to 1 for the short_range_assim_hawaii folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the short_range_assim_hawaii folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t00z.short_range.channel_rt.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t00z.short_range.channel_rt.f018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t08z.short_range.channel_rt.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range/nwm.t08z.short_range.channel_rt.f018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t00z.short_range.channel_rt.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t00z.short_range.channel_rt.f018.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t08z.short_range.channel_rt.f001.hawaii.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range/nwm.t08z.short_range.channel_rt.f018.hawaii.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_shortRangeAssimPuertorico.py b/test/test_shortRangeAssimPuertorico.py new file mode 100644 index 0000000..d80b0c2 --- /dev/null +++ b/test/test_shortRangeAssimPuertorico.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_short_range_assim_puertorico(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 3 + runinput = 1 # Set to 5 for the short_range_assim_puertorico folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the short_range_assim_puertorico folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico/nwm.t00z.short_range.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico/nwm.t00z.short_range.channel_rt.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico/nwm.t08z.short_range.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico/nwm.t08z.short_range.channel_rt.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico/nwm.t00z.short_range.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico/nwm.t00z.short_range.channel_rt.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico/nwm.t08z.short_range.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico/nwm.t08z.short_range.channel_rt.f018.puertorico.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/test_shortRangeAssimPuertoricoNoDa.py b/test/test_shortRangeAssimPuertoricoNoDa.py new file mode 100644 index 0000000..302de81 --- /dev/null +++ b/test/test_shortRangeAssimPuertoricoNoDa.py @@ -0,0 +1,59 @@ +import os +import unittest +from urlgennwm import ( + generate_urls_operational, +) # Import the generate_urls_operational function from your script + + +class TestGenerateURLs(unittest.TestCase): + def test_generate_urls_operational_for_short_range_assim_puertorico_no_da(self): + # Define test input values + start_date = "202201120000" + end_date = "202201130000" + fcst_cycle = [0, 8] + lead_time = [1, 18] + varinput = 1 + geoinput = 3 + runinput = 11 # Set to 11 for the short_range_assim_puertorico_no_da folder + urlbaseinput = 2 + meminput = 1 + write_to_file = True + + # Call the function to generate URLs + generate_urls_operational( + start_date, + end_date, + fcst_cycle, + lead_time, + varinput, + geoinput, + runinput, + urlbaseinput, + meminput, + write_to_file, + ) + + # Check if the generated 'filenamelist.txt' file exists + self.assertTrue(os.path.exists("filenamelist.txt")) + + # Define the expected URLs or patterns for the short_range_assim_puertorico_no_da folder + expected_urls = [ + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220112/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t00z.short_range_no_da.channel_rt.f018.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f001.puertorico.nc", + "https://nomads.ncep.noaa.gov/pub/data/nccf/com/nwm/post-processed/WMS/nwm.20220113/short_range_puertorico_no_da/nwm.t08z.short_range_no_da.channel_rt.f018.puertorico.nc", + ] + + # Read the content of the file and check for the expected content + with open("filenamelist.txt", "r") as file: + content = file.read() + for url in expected_urls: + self.assertIn(url, content) + + +if __name__ == "__main__": + unittest.main()