From 04ed44b09e57e652dcf4d4f9c624df75f4117fa7 Mon Sep 17 00:00:00 2001
From: lukas leufen <l.leufen@fz-juelich.de>
Date: Tue, 11 Feb 2020 16:27:38 +0100
Subject: [PATCH] updated sampling statement in some tests

---
 test/test_data_handling/test_data_generator.py   | 13 +++++++------
 test/test_data_handling/test_data_preparation.py |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/test/test_data_handling/test_data_generator.py b/test/test_data_handling/test_data_generator.py
index ad112549..142acd16 100644
--- a/test/test_data_handling/test_data_generator.py
+++ b/test/test_data_handling/test_data_generator.py
@@ -20,7 +20,7 @@ class TestDataGenerator:
     @pytest.fixture
     def gen(self):
         return DataGenerator(os.path.join(os.path.dirname(__file__), 'data'), 'AIRBASE', 'DEBW107', ['o3', 'temp'],
-                             'datetime', 'variables', 'o3')
+                             'datetime', 'variables', 'o3', start=2010, end=2014)
 
     class DummyDataPrep:
         def __init__(self, data):
@@ -42,13 +42,14 @@ class TestDataGenerator:
         assert gen.window_history_size == 7
         assert gen.window_lead_time == 4
         assert gen.transform_method == "standardise"
-        assert gen.kwargs == {}
+        assert gen.kwargs == {"start": 2010, "end": 2014}
 
     def test_repr(self, gen):
         path = os.path.join(os.path.dirname(__file__), 'data')
         assert gen.__repr__().rstrip() == f"DataGenerator(path='{path}', network='AIRBASE', stations=['DEBW107'], "\
                                           f"variables=['o3', 'temp'], station_type=None, interpolate_dim='datetime', " \
-                                          f"target_dim='variables', target_var='o3', **{{}})".rstrip()
+                                          f"target_dim='variables', target_var='o3', **{{'start': 2010, 'end': 2014}})"\
+                                          .rstrip()
 
     def test_len(self, gen):
         assert len(gen) == 1
@@ -99,7 +100,7 @@ class TestDataGenerator:
 
     def test_get_data_generator(self, gen):
         gen.kwargs = {"statistics_per_var": {'o3': 'dma8eu', 'temp': 'maximum'}}
-        file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}.pickle")
+        file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}_None_None_.pickle")
         if os.path.exists(file):
             os.remove(file)
         assert not os.path.exists(file)
@@ -113,7 +114,7 @@ class TestDataGenerator:
         assert os.stat(file).st_ctime > t
 
     def test_save_pickle_data(self, gen):
-        file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}.pickle")
+        file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}_2010_2014_.pickle")
         if os.path.exists(file):
             os.remove(file)
         assert not os.path.exists(file)
@@ -123,7 +124,7 @@ class TestDataGenerator:
         os.remove(file)
 
     def test_load_pickle_data(self, gen):
-        file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}.pickle")
+        file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}_2010_2014_.pickle")
         data = self.DummyDataPrep(np.ones((10, 2)))
         with open(file, "wb") as f:
             pickle.dump(data, f)
diff --git a/test/test_data_handling/test_data_preparation.py b/test/test_data_handling/test_data_preparation.py
index fd33cea9..72bacaf9 100644
--- a/test/test_data_handling/test_data_preparation.py
+++ b/test/test_data_handling/test_data_preparation.py
@@ -28,6 +28,7 @@ class TestDataPrep:
         d.station = ['DEBW107']
         d.variables = ['o3', 'temp']
         d.station_type = "background"
+        d.sampling = "daily"
         d.kwargs = None
         return d
 
-- 
GitLab