INCR-200 Migrate common/djangoapps/util/tests and migrations

This commit is contained in:
Jolyon Bloomfield
2019-04-05 00:46:05 -04:00
parent c4b0a6bfcf
commit 8adaca66d1
18 changed files with 60 additions and 21 deletions

View File

@@ -3,6 +3,8 @@
Tests for util.date_utils
"""
from __future__ import absolute_import
import unittest
from datetime import datetime, timedelta, tzinfo
@@ -130,7 +132,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
)
def test_usual_strftime_behavior(self, fmt_expected):
(fmt, expected) = fmt_expected
dtime = datetime(2013, 02, 14, 16, 41, 17)
dtime = datetime(2013, 2, 14, 16, 41, 17)
self.assertEqual(expected, strftime_localized(dtime, fmt))
# strftime doesn't like Unicode, so do the work in UTF8.
self.assertEqual(expected, dtime.strftime(fmt.encode('utf8')).decode('utf8'))
@@ -144,7 +146,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
)
def test_shortcuts(self, fmt_expected):
(fmt, expected) = fmt_expected
dtime = datetime(2013, 02, 14, 16, 41, 17)
dtime = datetime(2013, 2, 14, 16, 41, 17)
self.assertEqual(expected, strftime_localized(dtime, fmt))
@patch('util.date_utils.pgettext', fake_pgettext(translations={
@@ -163,7 +165,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
)
def test_translated_words(self, fmt_expected):
(fmt, expected) = fmt_expected
dtime = datetime(2013, 02, 14, 16, 41, 17)
dtime = datetime(2013, 2, 14, 16, 41, 17)
self.assertEqual(expected, strftime_localized(dtime, fmt))
@patch('util.date_utils.ugettext', fake_ugettext(translations={
@@ -183,7 +185,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
)
def test_translated_formats(self, fmt_expected):
(fmt, expected) = fmt_expected
dtime = datetime(2013, 02, 14, 16, 41, 17)
dtime = datetime(2013, 2, 14, 16, 41, 17)
self.assertEqual(expected, strftime_localized(dtime, fmt))
@patch('util.date_utils.ugettext', fake_ugettext(translations={
@@ -196,7 +198,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
)
def test_recursion_protection(self, fmt_expected):
(fmt, expected) = fmt_expected
dtime = datetime(2013, 02, 14, 16, 41, 17)
dtime = datetime(2013, 2, 14, 16, 41, 17)
self.assertEqual(expected, strftime_localized(dtime, fmt))
@ddt.data(
@@ -205,6 +207,6 @@ class StrftimeLocalizedTest(unittest.TestCase):
"%Y/%m/%d%",
)
def test_invalid_format_strings(self, fmt):
dtime = datetime(2013, 02, 14, 16, 41, 17)
dtime = datetime(2013, 2, 14, 16, 41, 17)
with self.assertRaises(ValueError):
strftime_localized(dtime, fmt)