From 6a32919d728d5588a81232efa0cca7e9e4415f46 Mon Sep 17 00:00:00 2001
From: David Trattnig <david@subsquare.at>
Date: Tue, 26 Mar 2024 12:39:41 +0100
Subject: [PATCH] test: loading timetable from fs removed

---
 tests/test_engine_clock_handler.py |  3 +-
 tests/test_scheduling_scheduler.py | 11 ++----
 tests/test_scheduling_timetable.py | 57 +-----------------------------
 3 files changed, 4 insertions(+), 67 deletions(-)

diff --git a/tests/test_engine_clock_handler.py b/tests/test_engine_clock_handler.py
index bf873112..4e44515e 100644
--- a/tests/test_engine_clock_handler.py
+++ b/tests/test_engine_clock_handler.py
@@ -49,8 +49,7 @@ class TestClockHandler(unittest.TestCase):
         self.engine = DotDict({"scheduler": DotDict({"timetable": self.timetable})})
 
     def tearDown(self):
-        # Clean up cache when finished
-        self.timetable.delete_timetable_file()
+        pass
 
     #
     # Test Cases
diff --git a/tests/test_scheduling_scheduler.py b/tests/test_scheduling_scheduler.py
index e803047a..ed4fa81d 100644
--- a/tests/test_scheduling_scheduler.py
+++ b/tests/test_scheduling_scheduler.py
@@ -219,7 +219,7 @@ class TestSchedulingScheduler(unittest.TestCase):
         # Delete the timetable file to isolate test case
         f = scheduler.timetable.timetable_file
         scheduler.timetable.timetable_file = f.replace("timetable.json", "timetable-test.json")
-        scheduler.timetable.delete_timetable_file()
+        #
 
         # Prune command registry
         CommandRegistry.prune()
@@ -287,7 +287,7 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Boot the scheduler
         scheduler = AuraScheduler(self.engine)
-        scheduler.timetable.delete_timetable_file()
+
         scheduler.boot()
         time.sleep(2)
         self.assertTrue(scheduler.is_alive())
@@ -302,7 +302,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +400)
@@ -316,7 +315,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +400)
@@ -350,7 +348,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +5)
@@ -367,7 +364,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +5, "3d_video://")
@@ -384,7 +380,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +400)
@@ -407,7 +402,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +400)
@@ -423,7 +417,6 @@ class TestSchedulingScheduler(unittest.TestCase):
 
         # Construct the scheduler
         scheduler = AuraScheduler(MockedEngine())
-        scheduler.timetable.delete_timetable_file()
 
         # Build some timetable
         scheduler.timetable.timetable = self.build_timetable(scheduler, -400, +30)
diff --git a/tests/test_scheduling_timetable.py b/tests/test_scheduling_timetable.py
index 503ca3e4..154c62db 100644
--- a/tests/test_scheduling_timetable.py
+++ b/tests/test_scheduling_timetable.py
@@ -85,8 +85,7 @@ class TestSchedulingTimetable(unittest.TestCase):
         self.timetable.timetable_file = f.replace("timetable.json", "timetable-test.json")
 
     def tearDown(self):
-        # Clean up cache when finished
-        self.timetable.delete_timetable_file()
+        pass
 
     #
     # Test Cases
@@ -280,9 +279,6 @@ class TestSchedulingTimetable(unittest.TestCase):
     def test_timetable_persist_and_load(self):
         print(self._testMethodName)
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
         now = SU.timestamp()
         ts1 = Timeslot(
             id=1, repetition_id=None, start=now - 180, end=now - 120, show=None, episode=None
@@ -312,12 +308,6 @@ class TestSchedulingTimetable(unittest.TestCase):
         self.timetable.persist_timetable()
         self.assertTrue(pathlib.Path("./.cache/timetable/timetable-test.json").is_file())
 
-        # Initialize timetable
-        self.timetable.timetable = None
-        self.assertIsNone(self.timetable.timetable)
-
-        # Load from file
-        self.timetable.load_timetable()
         self.assertIsNotNone(self.timetable.timetable)
         self.assertEqual(1, self.timetable.timetable[0].get_id())
         self.assertEqual(2, self.timetable.timetable[1].get_id())
@@ -331,9 +321,6 @@ class TestSchedulingTimetable(unittest.TestCase):
     def test_timetable_merge_and_persist(self):
         print(self._testMethodName)
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
         now = SU.timestamp()
         ts1 = Timeslot(
             id=1, repetition_id=None, start=now - 180, end=now - 120, show=None, episode=None
@@ -379,9 +366,6 @@ class TestSchedulingTimetable(unittest.TestCase):
     def test_timetable_merge_past_timeslots_local(self):
         print(self._testMethodName)
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
         now = SU.timestamp()
         ts1 = Timeslot(
             id=1, repetition_id=None, start=now - 180, end=now - 120, show=None, episode=None
@@ -405,9 +389,6 @@ class TestSchedulingTimetable(unittest.TestCase):
     def test_timetable_merge_past_timeslot_remote(self):
         print(self._testMethodName)
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
         now = SU.timestamp()
         ts1 = Timeslot(
             id=1, repetition_id=None, start=now - 180, end=now - 120, show=None, episode=None
@@ -429,9 +410,6 @@ class TestSchedulingTimetable(unittest.TestCase):
     def test_fetch_data(self):
         print(self._testMethodName)
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
         now = SU.timestamp()
         ts1 = Timeslot(
             id=1, repetition_id=None, start=now - 180, end=now - 120, show=None, episode=None
@@ -468,9 +446,6 @@ class TestSchedulingTimetable(unittest.TestCase):
         self.timetable.api_fetcher = fetcher
         self.timetable.refresh()
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
     def test_fetch_exception(self):
         print(self._testMethodName)
 
@@ -478,9 +453,6 @@ class TestSchedulingTimetable(unittest.TestCase):
         self.timetable.api_fetcher = fetcher
         self.timetable.refresh()
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
     def test_terminate(self):
         print(self._testMethodName)
 
@@ -491,33 +463,6 @@ class TestSchedulingTimetable(unittest.TestCase):
         self.timetable.refresh()
         self.timetable.terminate()
 
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
-    def test_timetable_file_exists(self):
-        print(self._testMethodName)
-
-        self.timetable.persist_timetable()
-        self.assertTrue(self.timetable.timetable_file_exists())
-
-        # Clear cache to keep test cases isolated
-        self.timetable.delete_timetable_file()
-
-    def test_timetable_file_delete(self):
-        print(self._testMethodName)
-
-        self.timetable.persist_timetable()
-
-        # Delete existing file
-        is_deleted = self.timetable.delete_timetable_file()
-        self.assertTrue(is_deleted)
-
-        # Delete non-existing file
-        is_deleted = self.timetable.delete_timetable_file()
-        self.assertTrue(is_deleted)
-
-        self.assertFalse(self.timetable.timetable_file_exists())
-
     def test_merger_remove_timeslots_deleted_remotely(self):
         print(self._testMethodName)
 
-- 
GitLab