Skip to content

Commit

Permalink
Raise Babel version, allow no-break space and upd year in test data
Browse files Browse the repository at this point in the history
  • Loading branch information
UlrichB22 committed Mar 19, 2023
1 parent 2e71373 commit 956da28
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
'setuptools_scm', # magically cares for version and packaged files
],
install_requires=[
'Babel<2.11.0', # internationalization support
'Babel>=2.10.0', # internationalization support
'blinker>=1.1', # event signalling (e.g. for change notification trigger)
'docutils>=0.18.1', # reST markup processing
'Markdown>=3.4.1', # Markdown markup processing
Expand Down
19 changes: 10 additions & 9 deletions src/moin/macros/_tests/test_Date.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
# Copyright: 2023 MoinMoin Project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand All @@ -18,19 +19,19 @@
class TestMacroDateTimeBase:
def test_parse_time(self):
MacroDateTimeBase_obj = MacroDateTimeBase()
test_time_args = '2011-08-07T11:11:11+0533'
test_time_args = '2023-08-07T11:11:11+0533'
ts = MacroDateTimeBase_obj.parse_time(test_time_args)
expected = 1312695491.0
expected = 1691386691.0
assert ts == expected

result = format_date_time(datetime.utcfromtimestamp(ts))
expected = '2011-08-07 05:38:11z'
expected = '2023-08-07 05:38:11z'
assert result == expected

flaskg.user.valid = True # show_time creates ISO 8601 dates if user is not logged in
result = format_date_time(datetime.utcfromtimestamp(ts))
expected = 'Aug 7, 2011, 5:38:11 AM' # comma after year was added in recent CLDR
assert result == expected
expected = ['Aug 7, 2023, 5:38:11\u202fAM', 'Aug 7, 2023, 5:38:11 AM', ] # TODO: remove 2nd entry later
assert result in expected

with pytest.raises(ValueError):
# things after next 10,000 years can't be predicted
Expand All @@ -51,18 +52,18 @@ def test_macro(self):
test_time = format_date(datetime.utcfromtimestamp(test_time))
assert result == test_time

arguments = ['2011-08-07T11:11:11+0533', 'argument2']
arguments = ['2023-08-07T11:11:11+0533', 'argument2']
result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
expected = 'Aug 7, 2011'
expected = 'Aug 7, 2023'
assert result == expected

flaskg.user.timezone = 'UTC'
flaskg.user.iso_8601 = True
result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
expected = '2011-08-07z'
expected = '2023-08-07z'
assert result == expected

flaskg.user.timezone = 'US/Arizona'
result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
expected = '2011-08-07'
expected = '2023-08-07'
assert result == expected
9 changes: 5 additions & 4 deletions src/moin/macros/_tests/test_DateTime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
# Copyright: 2023 MoinMoin Project
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -27,14 +28,14 @@ def test_Macro():
test_time = format_date_time(datetime.utcfromtimestamp(test_time))
assert test_time == result

arguments = ['2011-08-07T11:11:11', 'argument2']
arguments = ['2023-08-07T11:11:11', 'argument2']
result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
expected = 'Aug 7, 2011, 11:11:11 AM' # comma after year was added in recent CLDR
assert result == expected
expected = ['Aug 7, 2023, 11:11:11\u202fAM', 'Aug 7, 2023, 11:11:11 AM', ] # TODO: remove 2nd entry later
assert result in expected

flaskg.user.valid = False
result = macro_obj.macro('content', arguments, 'page_url', 'alternative')
expected = '2011-08-07 11:11:11z'
expected = '2023-08-07 11:11:11z'
assert result == expected

arguments = ['incorrect_argument']
Expand Down
4 changes: 2 additions & 2 deletions src/moin/utils/_tests/test_show_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def test_show_time_datetime_logged_in_local(self):
formatted_date = show_time.format_date(utc_dt=0)
assert formatted_date == 'Dec 31, 1969'
formatted_time = show_time.format_time(utc_dt=0)
assert formatted_time == '5:00:00 PM'
assert formatted_time in ['5:00:00\u202fPM', '5:00:00 PM', ] # TODO: 2nd string can be removed in future
formatted_date_time = show_time.format_date_time(utc_dt=0)
assert formatted_date_time == 'Dec 31, 1969, 5:00:00 PM'
assert formatted_date_time in ['Dec 31, 1969, 5:00:00\u202fPM', 'Dec 31, 1969, 5:00:00 PM', ] # TODO: ditto


coverage_modules = ['moin.utils.show_time']

0 comments on commit 956da28

Please sign in to comment.