Fix project tests for non-Central time zones

When running tests somewhere else than Central Time, `test_api_time()`
fails like

    AssertionError: '1985-10-27T02:00:00' != '1985-10-26T21:00:00'

`test_yaps_to_project_info()` fails in a similar way.

Pin the time zone to UTC for this test and adjust timestamps to UTC.
This commit is contained in:
Martin Pitt 2017-12-12 10:44:53 +01:00 committed by Brian C. Lane
parent e1af0c67bd
commit 53cd264ece
1 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
import time
import shutil
import tempfile
import unittest
@ -57,13 +59,15 @@ class ProjectsTest(unittest.TestCase):
self.tmp_dir = tempfile.mkdtemp(prefix="lorax.test.repo.")
self.config = configure(root_dir=self.tmp_dir, test_config=True)
self.yb = get_base_object(self.config)
os.environ["TZ"] = "UTC"
time.tzset()
@classmethod
def tearDownClass(self):
shutil.rmtree(self.tmp_dir)
def test_api_time(self):
self.assertEqual(api_time(499222800), "1985-10-26T21:00:00")
self.assertEqual(api_time(499222800), "1985-10-27T01:00:00")
def test_api_changelog(self):
self.assertEqual(api_changelog([[0,1,"Heavy!"]]), "Heavy!")
@ -82,7 +86,7 @@ class ProjectsTest(unittest.TestCase):
build = {"epoch":"epoch",
"release":"release",
"arch":"arch",
"build_time":"1985-10-26T21:00:00",
"build_time":"1985-10-27T01:00:00",
"changelog":"Heavy!",
"build_config_ref": "BUILD_CONFIG_REF",
"build_env_ref": "BUILD_ENV_REF",