"R6 Rainier - Launch 2804", "TJ Thomas Jefferson (ship)", "T1 Thomas Jefferson - Launch 3101", "T2 Thomas Jefferson - Launch 3102", "T3 Thomas Jefferson - Launch 2903", "T4 Thomas Jefferson - Launch 2904", "BH Bay Hydro II", "N1 NRT-1 Gulf", "N2 NRT-2 Atlantic", "N3 NRT-3 Pacific", "N4 NRT-4 Great Lakes", "N5 NRT-5 New York", "N6 NRT-6 San Francisco", "N7 NRT-7 Middle Atlantic", "FH Ferdinand R. Hassler (Ship)", "FA Fairweather (Ship)", "F5 Fairweather - Launch 2805", "F6 Fairweather - Launch 2806", "F7 Fairweather - Launch 2807", "F8 Fairweather - Launch 2808", "AR MCArthur", "NF Nancy Foster", "HI Hi'Ialakai", "GM Gloria Michelle", "EX Okeanos Explorer" ] institution_list = ["NOAA Office of Coast Survey", "UNH CCOM/JHC"] if Helper.is_pydro(): logger.debug("using pydro setup") default_use_woa_09 = 1 default_use_woa_13 = 0 default_use_woa_18 = 0 default_use_rtofs = 0 default_use_gomofs = 0 default_custom_woa09_folder = Helper.hstb_woa09_folder() default_custom_woa13_folder = Helper.hstb_woa13_folder() default_custom_woa18_folder = "" default_noaa_tools = 1 default_default_institution = institution_list[0] else: default_use_woa_09 = 1 default_use_woa_13 = 0
import logging from hyo2.abc.lib.helper import Helper from hyo2.abc.lib.lib_info import LibInfo from hyo2.abc.lib.logging import set_logging logger = logging.getLogger(__name__) set_logging(ns_list=["hyo2.abc"]) h = Helper(lib_info=LibInfo()) logger.debug("lib info:\n%s" % h.package_info()) logger.debug("is Pydro: %s" % Helper.is_pydro()) if Helper.is_pydro(): logger.debug("HSTB folder: %s" % Helper.hstb_folder()) logger.debug("atlases folder: %s" % Helper.hstb_atlases_folder()) logger.debug("WOA09 folder: %s" % Helper.hstb_woa09_folder()) logger.debug("WOA13 folder: %s" % Helper.hstb_woa13_folder())
class TestABCLibHelper(unittest.TestCase): def setUp(self): self.h = Helper(lib_info=LibInfo()) @unittest.skipIf(Helper.is_linux(), "test not supported on Linux") def test_explore_folder(self): self.assertTrue(self.h.explore_folder(__file__)) self.assertFalse(self.h.explore_folder(__file__ + ".fake")) self.assertTrue(self.h.explore_folder(os.path.dirname(__file__))) self.assertFalse(self.h.explore_folder(os.path.dirname(__file__) + "fake")) def test_first_match(self): # fake dict a_dict = { "a": 1, "b": 99, "c": 1, } # test if it gives back the first matching key self.assertTrue(Helper.first_match(a_dict, 1) in ["a", "c"]) # test if it raises with a not-existing value with self.assertRaises(RuntimeError): Helper.first_match(a_dict, 2) def test_is_64bit_os(self): self.assertIsInstance(self.h.is_64bit_os(), bool) def test_is_64bit_python(self): self.assertIsInstance(self.h.is_64bit_python(), bool) def test_is_darwin_linux_windows(self): self.assertIsInstance(self.h.is_darwin(), bool) self.assertIsInstance(self.h.is_linux(), bool) self.assertIsInstance(self.h.is_windows(), bool) self.assertTrue(any([self.h.is_linux(), self.h.is_darwin(), self.h.is_windows()])) def test_is_pydro(self): self.assertIsInstance(self.h.is_pydro(), bool) def test_is_url(self): self.assertTrue(self.h.is_url("https://www.hydroffice.org")) self.assertTrue(self.h.is_url("http://www.hydroffice.org")) self.assertFalse(self.h.is_url("ftp://fake/url")) def test_python_path(self): self.assertTrue(os.path.exists(self.h.python_path())) def test_package_info(self): self.assertIsInstance(self.h.package_info(qt_html=True), str) self.assertIsInstance(self.h.package_info(qt_html=False), str) def test_package_folder(self): self.assertTrue(os.path.exists(self.h.package_folder())) def test_hydroffice_folder(self): self.assertTrue(os.path.exists(self.h.hydroffice_folder()))