diff --git a/CHANGES.md b/CHANGES.md index 9db8076e..dd8cbd6e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ * Update Beautiful Soup 4.6.0 (r449) to 4.6.3 (r475) * Update CacheControl library 0.12.4 (bd94f7e) to 0.12.5 (cd91309) * Update Certifi 2018.01.18 (e225253) to 2018.08.24 (8be9f89) +* Update dateutil module 2.7.2 (ff03c0f) to 2.7.2 (49690ee) [develop changelog] diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index a3043c5c..8df65bf7 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -181,7 +181,7 @@ def _update_zoneinfo(): # remove the old zoneinfo file if cur_zoneinfo is not None: old_file = helpers.real_path( - ek.ek(join, sickbeard.ZONEINFO_DIR, cur_zoneinfo)) + ek.ek(os.path.join, sickbeard.ZONEINFO_DIR, cur_zoneinfo)) if ek.ek(os.path.exists, old_file): ek.ek(os.remove, old_file) # rename downloaded file @@ -190,6 +190,11 @@ def _update_zoneinfo(): if '_CLASS_ZONE_INSTANCE' in gettz.func_globals: gettz.func_globals.__setitem__('_CLASS_ZONE_INSTANCE', list()) tz.gettz.cache_clear() + from dateutil.zoneinfo import get_zonefile_instance + try: + delattr(get_zonefile_instance, '_cached_instance') + except AttributeError: + pass sb_timezone = get_tz() except: diff --git a/tests/network_timezone_tests.py b/tests/network_timezone_tests.py new file mode 100644 index 00000000..22c7a09a --- /dev/null +++ b/tests/network_timezone_tests.py @@ -0,0 +1,51 @@ +import unittest +import test_lib as test +import os.path +import datetime +from lib.dateutil import tz +import sickbeard +from sickbeard import network_timezones, helpers +import sickbeard.encodingKludge as ek + + +class NetworkTimezoneTests(test.SickbeardTestDBCase): + @classmethod + def tearDownClass(cls): + super(NetworkTimezoneTests, cls).tearDownClass() + cls.remove_zoneinfo() + try: + os.rmdir(sickbeard.ZONEINFO_DIR) + except (StandardError, Exception): + pass + + @classmethod + def setUpClass(cls): + super(NetworkTimezoneTests, cls).setUpClass() + cls.remove_zoneinfo() + + @classmethod + def remove_zoneinfo(cls): + # delete all existing zoneinfo files + for (path, dirs, files) in ek.ek(os.walk, helpers.real_path(sickbeard.ZONEINFO_DIR)): + for filename in files: + if filename.endswith('.tar.gz'): + file_w_path = ek.ek(os.path.join, path, filename) + try: + ek.ek(os.remove, file_w_path) + except (StandardError, Exception): + pass + + def test_timezone(self): + network_timezones.update_network_dict() + network_timezones.sb_timezone = tz.gettz('CET', zoneinfo_priority=True) + d = datetime.date(2018, 9, 2).toordinal() + t = 'Monday 9:00 PM' + network = 'NBC' + r = network_timezones.parse_date_time(d, t, network) + local_date = datetime.datetime(2018, 9, 3, 3, 0, 0).replace(tzinfo=tz.gettz('CET', zoneinfo_priority=True)) + self.assertEqual(r, local_date) + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(NetworkTimezoneTests) + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/tests/test_lib.py b/tests/test_lib.py index 9ecdb57b..e1eca26b 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -96,6 +96,7 @@ createTestLogFolder() sickbeard.logger.sb_log_instance.init_logging(False) sickbeard.CACHE_DIR = os.path.join(TESTDIR, 'cache') +sickbeard.ZONEINFO_DIR = os.path.join(TESTDIR, 'zoneinfo') createTestCacheFolder() #=================