From b6cd9b9efd3415a65047673b73d275348e78eb07 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 1 Apr 2024 17:54:05 -0700 Subject: [PATCH] add testing framework --- tests/test_automatic_weather_stations.py | 65 ++++++++++++++++++++++++ tests/test_hydrology.py | 21 ++++++++ tests/test_remote_sensing.py | 21 ++++++++ tests/test_topography.py | 21 ++++++++ tests/test_utils.py | 21 ++++++++ 5 files changed, 149 insertions(+) create mode 100644 tests/test_automatic_weather_stations.py create mode 100644 tests/test_hydrology.py create mode 100644 tests/test_remote_sensing.py create mode 100644 tests/test_topography.py create mode 100644 tests/test_utils.py diff --git a/tests/test_automatic_weather_stations.py b/tests/test_automatic_weather_stations.py new file mode 100644 index 0000000..bd5b6f1 --- /dev/null +++ b/tests/test_automatic_weather_stations.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +"""Tests for `easysnowdata` package.""" + + +import unittest + +from easysnowdata import automatic_weather_stations +import pandas as pd +import geopandas as gpd + + +class TestAutomaticWeatherStations(unittest.TestCase): + """Tests for `easysnowdata` package.""" + + @classmethod + def setUpClass(self): + """Set up test fixtures, if any.""" + bbox_gdf = gpd.read_file('https://github.com/egagli/sar_snowmelt_timing/raw/main/input/shapefiles/mt_rainier.geojson') + self.StationCollectionSNOTEL = automatic_weather_stations.StationCollection(snotel_stations=True, ccss_stations=False) + self.StationCollectionCCSS = automatic_weather_stations.StationCollection(snotel_stations=False, ccss_stations=True) + self.StationCollectionAll = automatic_weather_stations.StationCollection(snotel_stations=True, ccss_stations=True) + self.StationCollectionAllOrdered = automatic_weather_stations.StationCollection(snotel_stations=True, ccss_stations=False, sortby_dist_to_geom=bbox_gdf) + + @classmethod + def tearDownClass(self): + """Tear down test fixtures, if any.""" + self.StationCollectionSNOTEL = None + self.StationCollectionCCSS = None + self.StationCollectionAll = None + self.StationCollectionAllOrdered = None + + + def test_get_all_stations(self): + """Test get_all_stations method in automatic_weather_stations class.""" + self.StationCollection.get_all_stations() + self.assertIsInstance(self.StationCollectionAll.stations, gpd.GeoDataFrame) + self.assertGreater(len(self.StationCollectionAll.stations), 960) + + def test_choose_station(self): + """Test choose_station method in automatic_weather_stations class.""" + self.StationCollection.choose_station() + self.assertIsInstance(self.StationCollection.station, dict) + + def test_get_data(self): + """Test get_data method in automatic_weather_stations class.""" + + self.StationCollection.get_data() + self.assertIsInstance(self.StationCollection.data, pd.DataFrame) + + def test_get_single_station_data(self): + """Test get_single_station_data method in automatic_weather_stations class.""" + self.StationCollection.get_single_station_data() + self.assertIsInstance(self.StationCollection.data, pd.DataFrame) + + def test_multiple_station_data(self): + """Test multiple_station_data method in automatic_weather_stations class.""" + self.StationCollection.multiple_station_data() + self.assertIsInstance(self.StationCollection.data, pd.DataFrame) + + def test_get_entire_data_archive(self): + """Test get_entire_data_archive method in automatic_weather_stations class.""" + self.StationCollection.get_entire_data_archive() + self.assertIsInstance(self.StationCollection.data, pd.DataFrame) + diff --git a/tests/test_hydrology.py b/tests/test_hydrology.py new file mode 100644 index 0000000..c34fb03 --- /dev/null +++ b/tests/test_hydrology.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +"""Tests for `easysnowdata` package.""" + + +import unittest + +from easysnowdata import easysnowdata + + +class TestEasysnowdata(unittest.TestCase): + """Tests for `easysnowdata` package.""" + + def setUp(self): + """Set up test fixtures, if any.""" + + def tearDown(self): + """Tear down test fixtures, if any.""" + + def test_000_something(self): + """Test something.""" diff --git a/tests/test_remote_sensing.py b/tests/test_remote_sensing.py new file mode 100644 index 0000000..c34fb03 --- /dev/null +++ b/tests/test_remote_sensing.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +"""Tests for `easysnowdata` package.""" + + +import unittest + +from easysnowdata import easysnowdata + + +class TestEasysnowdata(unittest.TestCase): + """Tests for `easysnowdata` package.""" + + def setUp(self): + """Set up test fixtures, if any.""" + + def tearDown(self): + """Tear down test fixtures, if any.""" + + def test_000_something(self): + """Test something.""" diff --git a/tests/test_topography.py b/tests/test_topography.py new file mode 100644 index 0000000..c34fb03 --- /dev/null +++ b/tests/test_topography.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +"""Tests for `easysnowdata` package.""" + + +import unittest + +from easysnowdata import easysnowdata + + +class TestEasysnowdata(unittest.TestCase): + """Tests for `easysnowdata` package.""" + + def setUp(self): + """Set up test fixtures, if any.""" + + def tearDown(self): + """Tear down test fixtures, if any.""" + + def test_000_something(self): + """Test something.""" diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..c34fb03 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +"""Tests for `easysnowdata` package.""" + + +import unittest + +from easysnowdata import easysnowdata + + +class TestEasysnowdata(unittest.TestCase): + """Tests for `easysnowdata` package.""" + + def setUp(self): + """Set up test fixtures, if any.""" + + def tearDown(self): + """Tear down test fixtures, if any.""" + + def test_000_something(self): + """Test something."""