diff --git a/plone/__init__.py b/plone/__init__.py index de40ea7..5284146 100644 --- a/plone/__init__.py +++ b/plone/__init__.py @@ -1 +1 @@ -__import__('pkg_resources').declare_namespace(__name__) +__import__("pkg_resources").declare_namespace(__name__) diff --git a/plone/event/adapters.py b/plone/event/adapters.py index 2ce3afc..2549298 100644 --- a/plone/event/adapters.py +++ b/plone/event/adapters.py @@ -14,7 +14,7 @@ class EventAccessor: """ def __init__(self, context): - object.__setattr__(self, 'context', context) + object.__setattr__(self, "context", context) def __getattr__(self, name): return getattr(self.context, name) diff --git a/plone/event/interfaces.py b/plone/event/interfaces.py index 8dc85bc..5f3af6e 100644 --- a/plone/event/interfaces.py +++ b/plone/event/interfaces.py @@ -3,9 +3,7 @@ class IEvent(Interface): - """Event type marker interface. - - """ + """Event type marker interface.""" class IEventRecurrence(Interface): @@ -20,8 +18,9 @@ class IOccurrence(Interface): occurrence. """ - start = Attribute('Occurrence start date') - end = Attribute('Occurrence end date') + + start = Attribute("Occurrence start date") + end = Attribute("Occurrence end date") class ICalendarAccessor(Interface): @@ -30,16 +29,15 @@ class ICalendarAccessor(Interface): A calendar is a collection of calendar components, like events. """ - uid = Attribute('UID of the calendar. Autogenerated, read only.') + + uid = Attribute("UID of the calendar. Autogenerated, read only.") # rw attributes - title = Attribute('Calendar title.') - description = Attribute('Calendar description text.') - timezone = Attribute('Default timezone of the calendar.') + title = Attribute("Calendar title.") + description = Attribute("Calendar description text.") + timezone = Attribute("Default timezone of the calendar.") def items(self): - """Return a list of calendar component items, like events. - - """ + """Return a list of calendar component items, like events.""" class IEventAccessor(Interface): @@ -51,40 +49,38 @@ class IEventAccessor(Interface): """ # ro attributes - uid = Attribute('UID of the event. Autogenerated, read only.') - created = Attribute('Python datetime of the event creation timestamp.') - duration = Attribute('Duration of the event. Computed attribute.') + uid = Attribute("UID of the event. Autogenerated, read only.") + created = Attribute("Python datetime of the event creation timestamp.") + duration = Attribute("Duration of the event. Computed attribute.") # reference url = Attribute( - 'Cannonical, unique url of the event. External events ' - 'are referenced by the origin url unless explicitly set.' + "Cannonical, unique url of the event. External events " + "are referenced by the origin url unless explicitly set." ) # rw attributes - last_modified = Attribute('Last modified Python datetime.') - title = Attribute('Event title.') - description = Attribute('Event description text.') - start = Attribute('Event start date as Python datetime.') - end = Attribute('Event end date as Python datetime.') - whole_day = Attribute('Event lasts whole day.') - open_end = Attribute('Event has no defined end time.') - timezone = Attribute('Timezone of the event. A pytz timezone identifier.') - recurrence = Attribute('RFC5545 compatible recurrence definition.') - location = Attribute('Location of the event.') - attendees = Attribute('List of attendees.') - contact_name = Attribute('Contact name.') - contact_email = Attribute('Contact email.') - contact_phone = Attribute('Contact phone.') - event_url = Attribute('Website of the event.') - subjects = Attribute('Categories.') - text = Attribute('Body text of the event.') + last_modified = Attribute("Last modified Python datetime.") + title = Attribute("Event title.") + description = Attribute("Event description text.") + start = Attribute("Event start date as Python datetime.") + end = Attribute("Event end date as Python datetime.") + whole_day = Attribute("Event lasts whole day.") + open_end = Attribute("Event has no defined end time.") + timezone = Attribute("Timezone of the event. A pytz timezone identifier.") + recurrence = Attribute("RFC5545 compatible recurrence definition.") + location = Attribute("Location of the event.") + attendees = Attribute("List of attendees.") + contact_name = Attribute("Contact name.") + contact_email = Attribute("Contact email.") + contact_phone = Attribute("Contact phone.") + event_url = Attribute("Website of the event.") + subjects = Attribute("Categories.") + text = Attribute("Body text of the event.") class IRecurrenceSupport(Interface): - """Event type recurrence adatper. - - """ + """Event type recurrence adatper.""" def occurrences(self, range_start, range_end): """Return a list of IOccurrence objects with custom attributes of the @@ -100,9 +96,7 @@ def occurrences(self, range_start, range_end): class IICalendar(Interface): - """Adapter, which is used to construct an icalendar object. - - """ + """Adapter, which is used to construct an icalendar object.""" class IICalendarEventComponent(Interface): @@ -155,37 +149,38 @@ class / created / description / geo / resources / rdate / x-prop / iana-prop """ - dtstart = Attribute('Start Date/Time') - dtend = Attribute('End Date/Time') - duration = Attribute('Duration') - rrule = Attribute('Recurrence Rule') - description = Attribute('Description') - location = Attribute('Location') - summary = Attribute('Summary') - url = Attribute('Url') - attendee = Attribute('Attendee') - categories = Attribute('Categories') - contact = Attribute('Contact') - - exdate = Attribute('Exdate') - rdate = Attribute('Rdate') - - dtstamp = Attribute('Timestamp') - uid = Attribute('Unique identifier') - klass = Attribute('Class') # class - created = Attribute('Created') - geo = Attribute('Geo') - last_mod = Attribute('Last Modified') # last-mod - organizer = Attribute('Organizer') - priority = Attribute('Priority') - seq = Attribute('Seq') - status = Attribute('Status') - transp = Attribute('Transp') - recurid = Attribute('Recurid') - attach = Attribute('Attach') - comment = Attribute('Comment') - rstatus = Attribute('Rstatus') - related = Attribute('Related') - resources = Attribute('Resources') - x_prop = Attribute('X Prop') # x-prop - iana_prop = Attribute('Iana Prop') # iana-prop + + dtstart = Attribute("Start Date/Time") + dtend = Attribute("End Date/Time") + duration = Attribute("Duration") + rrule = Attribute("Recurrence Rule") + description = Attribute("Description") + location = Attribute("Location") + summary = Attribute("Summary") + url = Attribute("Url") + attendee = Attribute("Attendee") + categories = Attribute("Categories") + contact = Attribute("Contact") + + exdate = Attribute("Exdate") + rdate = Attribute("Rdate") + + dtstamp = Attribute("Timestamp") + uid = Attribute("Unique identifier") + klass = Attribute("Class") # class + created = Attribute("Created") + geo = Attribute("Geo") + last_mod = Attribute("Last Modified") # last-mod + organizer = Attribute("Organizer") + priority = Attribute("Priority") + seq = Attribute("Seq") + status = Attribute("Status") + transp = Attribute("Transp") + recurid = Attribute("Recurid") + attach = Attribute("Attach") + comment = Attribute("Comment") + rstatus = Attribute("Rstatus") + related = Attribute("Related") + resources = Attribute("Resources") + x_prop = Attribute("X Prop") # x-prop + iana_prop = Attribute("Iana Prop") # iana-prop diff --git a/plone/event/recurrence.py b/plone/event/recurrence.py index 7dd27ea..e2b528b 100644 --- a/plone/event/recurrence.py +++ b/plone/event/recurrence.py @@ -15,12 +15,12 @@ def recurrence_sequence_ical( - start, - recrule=None, - from_=None, - until=None, - count=None, - duration=None, + start, + recrule=None, + from_=None, + until=None, + count=None, + duration=None, ): """Calculates a sequence of datetime objects from a recurrence rule following the RFC2445 specification, using python-dateutil recurrence @@ -67,7 +67,7 @@ def recurrence_sequence_ical( _from = tzdel(from_) _until = tzdel(until) if duration: - assert (isinstance(duration, datetime.timedelta)) + assert isinstance(duration, datetime.timedelta) else: duration = datetime.timedelta(0) @@ -87,16 +87,16 @@ def recurrence_sequence_ical( # time for UNTIL, RDATE and EXDATE. t0 = start.time() # set initial time information. # First, replace all times in the recurring rule with starttime - t0str = f'T{t0.hour:02d}{t0.minute:02d}{t0.second:02d}' + t0str = f"T{t0.hour:02d}{t0.minute:02d}{t0.second:02d}" # Replace any times set to 000000 with start time, not all # rrules are set by a specific broken widget. Don't waste time # subbing if the start time is already 000000. - if t0str != 'T000000': - recrule = re.sub(r'T000000', t0str, recrule) + if t0str != "T000000": + recrule = re.sub(r"T000000", t0str, recrule) # Then, replace incorrect until times with the end of the day recrule = re.sub( - r'(UNTIL[^T]*[0-9]{8})T(000000)', - r'\1T235959', + r"(UNTIL[^T]*[0-9]{8})T(000000)", + r"\1T235959", recrule, ) @@ -140,13 +140,13 @@ def recurrence_sequence_ical( def recurrence_sequence_timedelta( - start, - delta=None, - until=None, - count=None, - dst=DSTAUTO, + start, + delta=None, + until=None, + count=None, + dst=DSTAUTO, ): - """ Calculates a sequence of datetime objects from a timedelta integer, + """Calculates a sequence of datetime objects from a timedelta integer, which defines the minutes between each occurence. :param start: datetime or DateTime instance of the date from which the @@ -204,7 +204,7 @@ def recurrence_sequence_timedelta( def recurrence_int_sequence(sequence): - """ Generates a sequence of integer representations from a sequence of + """Generates a sequence of integer representations from a sequence of dateime instances. :param sequence: An iterable sequence of datetime instances. diff --git a/plone/event/tests/test_adapters.py b/plone/event/tests/test_adapters.py index ad51528..df92e79 100644 --- a/plone/event/tests/test_adapters.py +++ b/plone/event/tests/test_adapters.py @@ -15,15 +15,17 @@ class MockObject: class TestAdapters(unittest.TestCase): def setUp(self): import zope.component - context = xmlconfig.file('meta.zcml', zope.component) - xmlconfig.file('configure.zcml', zope.component, context=context) + + context = xmlconfig.file("meta.zcml", zope.component) + xmlconfig.file("configure.zcml", zope.component, context=context) import plone.event - xmlconfig.file('configure.zcml', plone.event, context=context) + + xmlconfig.file("configure.zcml", plone.event, context=context) def test_event_accessor(self): obj = MockObject() - tz = pytz.timezone('Europe/Vienna') + tz = pytz.timezone("Europe/Vienna") obj.start = datetime(2012, 12, 12, 10, 0, tzinfo=tz) obj.end = datetime(2012, 12, 12, 12, 0, tzinfo=tz) zope.interface.alsoProvides(obj, IEvent) @@ -48,9 +50,9 @@ def test_event_accessor(self): acc.something = True self.assertTrue(acc.something == obj.something is True) del acc.something - self.assertTrue(hasattr(acc, 'something') is False) - self.assertTrue(hasattr(obj, 'something') is False) + self.assertTrue(hasattr(acc, "something") is False) + self.assertTrue(hasattr(obj, "something") is False) del acc.start - self.assertTrue(hasattr(acc, 'start') is False) - self.assertTrue(hasattr(obj, 'start') is False) + self.assertTrue(hasattr(acc, "start") is False) + self.assertTrue(hasattr(obj, "start") is False) diff --git a/plone/event/tests/test_doctest.py b/plone/event/tests/test_doctest.py index 001e083..6e7b759 100644 --- a/plone/event/tests/test_doctest.py +++ b/plone/event/tests/test_doctest.py @@ -7,11 +7,13 @@ OPTIONFLAGS = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS DOCFILES = [ - 'recurrence.rst', - 'recurrence_dateutil.rst', - 'utils.rst', + "recurrence.rst", + "recurrence_dateutil.rst", + "utils.rst", +] +DOCMODS = [ + "plone.event.utils", ] -DOCMODS = ['plone.event.utils', ] def test_suite(): @@ -19,24 +21,19 @@ def test_suite(): suite.addTests( [ doctest.DocFileSuite( - os.path.join(os.path.dirname(__file__), '..', docfile), + os.path.join(os.path.dirname(__file__), "..", docfile), module_relative=False, optionflags=OPTIONFLAGS, - tearDown=tearDown + tearDown=tearDown, ) for docfile in DOCFILES ] ) suite.addTests( - [ - doctest.DocTestSuite( - docmod, optionflags=OPTIONFLAGS - ) - for docmod in DOCMODS - ] + [doctest.DocTestSuite(docmod, optionflags=OPTIONFLAGS) for docmod in DOCMODS] ) return suite -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') +if __name__ == "__main__": + unittest.main(defaultTest="test_suite") diff --git a/plone/event/tests/test_recurrence_int_sequence.py b/plone/event/tests/test_recurrence_int_sequence.py index b858a9c..9812fb4 100644 --- a/plone/event/tests/test_recurrence_int_sequence.py +++ b/plone/event/tests/test_recurrence_int_sequence.py @@ -4,10 +4,11 @@ class TestRecurrenceIntSequence(unittest.TestCase): - @mock.patch('plone.event.recurrence.dt2int') + @mock.patch("plone.event.recurrence.dt2int") def test_recrule_str_(self, dt2int): from plone.event.recurrence import recurrence_int_sequence + sequence = [1, 2, 3] - dt2int.return_value = 'a' + dt2int.return_value = "a" res = [a for a in recurrence_int_sequence(sequence)] - self.assertEqual(res, ['a', 'a', 'a']) + self.assertEqual(res, ["a", "a", "a"]) diff --git a/plone/event/tests/test_recurrence_sequence_ical.py b/plone/event/tests/test_recurrence_sequence_ical.py index ae08c8f..25f1887 100644 --- a/plone/event/tests/test_recurrence_sequence_ical.py +++ b/plone/event/tests/test_recurrence_sequence_ical.py @@ -5,6 +5,7 @@ class TestRecurrenceSequenceIcal(unittest.TestCase): def test_start(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) seq = recurrence_sequence_ical(start) results = [res for res in seq] @@ -13,18 +14,20 @@ def test_start(self): def test_recrule_str(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) - recrule = 'FREQ=DAILY;INTERVAL=10;COUNT=5' + recrule = "FREQ=DAILY;INTERVAL=10;COUNT=5" seq = recurrence_sequence_ical(start, recrule=recrule) results = [res for res in seq] self.assertEqual(len(results), 5) def test_recrule_str_rdate(self): """Test, if an RDATE date has the correct time set. - See: "BUGFIX WRONG RDATE TIME" in recurrence.py + See: "BUGFIX WRONG RDATE TIME" in recurrence.py """ from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23, 10, 10) recrule = """FREQ=DAILY;INTERVAL=1;COUNT=3 RDATE:20111129T000000""" @@ -34,22 +37,22 @@ def test_recrule_str_rdate(self): self.assertEqual(results[0].time(), results[-1].time()) def test_recrule_str_exdate(self): - """Test, if an EXDATE date are not in the resulting recurrence set. - """ + """Test, if an EXDATE date are not in the resulting recurrence set.""" from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical import pytz - at = pytz.timezone('Europe/Vienna') + + at = pytz.timezone("Europe/Vienna") start = at.localize(datetime(2013, 6, 29, 10, 10)) - recrule = 'RRULE:FREQ=DAILY;COUNT=4\r\nEXDATE:20130630T000000,20130701T000000\r\nRDATE:20130706T000000,20130809T000000' # noqa + recrule = "RRULE:FREQ=DAILY;COUNT=4\r\nEXDATE:20130630T000000,20130701T000000\r\nRDATE:20130706T000000,20130809T000000" # noqa seq = recurrence_sequence_ical(start, recrule=recrule) res = [res for res in seq] res_test = [ at.localize(datetime(2013, 6, 29, 10, 10)), at.localize(datetime(2013, 7, 2, 10, 10)), at.localize(datetime(2013, 7, 6, 10, 10)), - at.localize(datetime(2013, 8, 9, 10, 10)) + at.localize(datetime(2013, 8, 9, 10, 10)), ] self.assertEqual(len(res), 4) self.assertEqual(res, res_test) @@ -62,16 +65,17 @@ def test_recrule_str_until(self): from plone.event.recurrence import recurrence_sequence_ical import pytz - at = pytz.timezone('Europe/Vienna') + + at = pytz.timezone("Europe/Vienna") start = at.localize(datetime(2013, 6, 29, 10, 10)) - recrule = 'RRULE:FREQ=DAILY;UNTIL=20130702T000000' + recrule = "RRULE:FREQ=DAILY;UNTIL=20130702T000000" seq = recurrence_sequence_ical(start, recrule=recrule) res = [res for res in seq] res_test = [ at.localize(datetime(2013, 6, 29, 10, 10)), at.localize(datetime(2013, 6, 30, 10, 10)), at.localize(datetime(2013, 7, 1, 10, 10)), - at.localize(datetime(2013, 7, 2, 10, 10)) + at.localize(datetime(2013, 7, 2, 10, 10)), ] self.assertEqual(len(res), 4) self.assertEqual(res, res_test) @@ -79,6 +83,7 @@ def test_recrule_str_until(self): def test_recrule_from_until(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) recrule = None from_ = datetime(2011, 11, 1) @@ -95,8 +100,9 @@ def test_recrule_from_until(self): def test_recrule_str_more_than_MAXCOUNT(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) - recrule = 'FREQ=DAILY;INTERVAL=10;COUNT=1001' + recrule = "FREQ=DAILY;INTERVAL=10;COUNT=1001" seq = recurrence_sequence_ical(start, recrule=recrule) results = [res for res in seq] self.assertEqual(len(results), 1000) @@ -104,8 +110,9 @@ def test_recrule_str_more_than_MAXCOUNT(self): def test_recrule_str_more_than_count(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) - recrule = 'FREQ=DAILY;INTERVAL=10;COUNT=10' + recrule = "FREQ=DAILY;INTERVAL=10;COUNT=10" count = 5 seq = recurrence_sequence_ical(start, recrule=recrule, count=count) results = [res for res in seq] @@ -114,8 +121,9 @@ def test_recrule_str_more_than_count(self): def test_recrule_from(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) - recrule = 'FREQ=DAILY;INTERVAL=1;COUNT=5' + recrule = "FREQ=DAILY;INTERVAL=1;COUNT=5" from_ = datetime(2011, 11, 25) until = datetime(2011, 11, 27) seq = recurrence_sequence_ical( @@ -130,8 +138,9 @@ def test_recrule_from(self): def test_recrule_until(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 24) - recrule = 'FREQ=DAILY;INTERVAL=1;COUNT=5' + recrule = "FREQ=DAILY;INTERVAL=1;COUNT=5" from_ = datetime(2011, 11, 23) until = datetime(2011, 11, 27) seq = recurrence_sequence_ical( @@ -144,13 +153,13 @@ def test_recrule_until(self): self.assertEqual(len(results), 4) def test_recrule_from_until_with_duration(self): - """Should include events ranging into the queried timerange. - """ + """Should include events ranging into the queried timerange.""" from datetime import datetime from datetime import timedelta from plone.event.recurrence import recurrence_sequence_ical + start = datetime(2011, 11, 23) - recrule = 'FREQ=DAILY;INTERVAL=1;COUNT=5' + recrule = "FREQ=DAILY;INTERVAL=1;COUNT=5" from_ = datetime(2011, 11, 26) until = datetime(2011, 11, 27) seq = recurrence_sequence_ical( @@ -168,6 +177,6 @@ def test_recrule_until_with_timezone(self): from plone.event.recurrence import recurrence_sequence_ical start = datetime(2011, 11, 24) - recrule = 'RRULE:FREQ=DAILY;UNTIL=20111130T000000Z' + recrule = "RRULE:FREQ=DAILY;UNTIL=20111130T000000Z" seq = list(recurrence_sequence_ical(start, recrule=recrule)) self.assertEqual(len(seq), 7) diff --git a/plone/event/tests/test_recurrence_sequence_timedelta.py b/plone/event/tests/test_recurrence_sequence_timedelta.py index fdb21af..9ca7210 100644 --- a/plone/event/tests/test_recurrence_sequence_timedelta.py +++ b/plone/event/tests/test_recurrence_sequence_timedelta.py @@ -5,6 +5,7 @@ class TestRecurrenceSequenceTimedelta(unittest.TestCase): def test_delta_None(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_timedelta + start = datetime(2011, 11, 23) until = datetime(2011, 11, 24) td = recurrence_sequence_timedelta(start, until=until) @@ -14,6 +15,7 @@ def test_delta_None(self): def test_delta_zero(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_timedelta + start = datetime(2011, 11, 23) delta = 0 until = datetime(2011, 11, 24) @@ -24,6 +26,7 @@ def test_delta_zero(self): def test_until_None(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_timedelta + start = datetime(2011, 11, 23) delta = 1 td = recurrence_sequence_timedelta(start, delta=delta) @@ -33,6 +36,7 @@ def test_until_None(self): def test_delta_an_hour_until_next_day(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_timedelta + start = datetime(2011, 11, 23) delta = 60 until = datetime(2011, 11, 24) @@ -43,6 +47,7 @@ def test_delta_an_hour_until_next_day(self): def test_recur_more_than_MAXCOUNT(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_timedelta + start = datetime(2011, 11, 23) delta = 1 until = datetime(2012, 11, 23) @@ -53,6 +58,7 @@ def test_recur_more_than_MAXCOUNT(self): def test_recur_more_than_count(self): from datetime import datetime from plone.event.recurrence import recurrence_sequence_timedelta + start = datetime(2011, 11, 23) delta = 1 until = datetime(2011, 11, 24) diff --git a/plone/event/tests/test_utils.py b/plone/event/tests/test_utils.py index 0576920..ca82a01 100644 --- a/plone/event/tests/test_utils.py +++ b/plone/event/tests/test_utils.py @@ -4,41 +4,47 @@ class TestUtils(unittest.TestCase): - @mock.patch('plone.event.utils.pytz') - @mock.patch('plone.event.utils.os') + @mock.patch("plone.event.utils.pytz") + @mock.patch("plone.event.utils.os") def test_default_timezone(self, os, pytz): from plone.event.utils import default_timezone - os.environ.keys.return_value = ['TZ'] + + os.environ.keys.return_value = ["TZ"] os.environ = mock.MagicMock() - pytz.timezone().zone = 'zone' - self.assertEqual(default_timezone(), 'zone') + pytz.timezone().zone = "zone" + self.assertEqual(default_timezone(), "zone") def test_utcoffset_normalize(self): from plone.event.utils import utcoffset_normalize + date = mock.Mock() date.replace = mock.Mock(side_effect=KeyError) self.assertEqual(utcoffset_normalize(date), date) - @mock.patch('plone.event.utils.guesstz') - @mock.patch('plone.event.utils.utctz') + @mock.patch("plone.event.utils.guesstz") + @mock.patch("plone.event.utils.utctz") def test_pydt__missing_zone_is_None(self, utctz, guesstz): from plone.event.utils import pydt + dt = mock.Mock() dt.toZone.return_value = dt dt.parts.return_value = (2011, 11, 24, 11, 39, 00) guesstz.return_value = None import pytz - utctz.return_value = pytz.timezone('UTC') + + utctz.return_value = pytz.timezone("UTC") pydt(dt) self.assertTrue(utctz.called) - @mock.patch('plone.event.utils.guesstz') - @mock.patch('plone.event.utils.utctz') + @mock.patch("plone.event.utils.guesstz") + @mock.patch("plone.event.utils.utctz") def test_pydt__missing_zone_is_not_None(self, utctz, guesstz): from plone.event.utils import pydt + dt = mock.Mock() import pytz - utctz.return_value = pytz.timezone('UTC') + + utctz.return_value = pytz.timezone("UTC") missing_zone = utctz() dt.toZone.return_value = dt dt.parts.return_value = (2011, 11, 24, 11, 39, 00) @@ -48,16 +54,19 @@ def test_pydt__missing_zone_is_not_None(self, utctz, guesstz): def test_pydt__wrong_type(self): from plone.event.utils import pydt - self.assertEqual(pydt('wrongtype'), None) + + self.assertEqual(pydt("wrongtype"), None) def test_dt2int_dt_is_None(self): from plone.event.utils import dt2int + self.assertFalse(dt2int(None)) - @mock.patch('plone.event.utils.MAX32', 0) - @mock.patch('plone.event.utils.utc') + @mock.patch("plone.event.utils.MAX32", 0) + @mock.patch("plone.event.utils.utc") def test_dt2int_less_MAX32(self, utc): from plone.event.utils import dt2int + dt = mock.Mock() dd = mock.Mock() utc.return_value = dd @@ -68,10 +77,11 @@ def test_dt2int_less_MAX32(self, utc): dd.minute = 16 self.assertRaises(OverflowError, lambda: dt2int(dt)) - @mock.patch('plone.event.utils.MAX32', 1077778937) - @mock.patch('plone.event.utils.utc') + @mock.patch("plone.event.utils.MAX32", 1077778937) + @mock.patch("plone.event.utils.utc") def test_dt2int_more_MAX32(self, utc): from plone.event.utils import dt2int + dt = mock.Mock() dd = mock.Mock() utc.return_value = dd diff --git a/setup.py b/setup.py index 93f57df..b6ccb92 100644 --- a/setup.py +++ b/setup.py @@ -2,15 +2,13 @@ from setuptools import setup -version = '1.4.3.dev0' +version = "1.4.3.dev0" setup( - name='plone.event', + name="plone.event", version=version, description="Event and calendaring related tools not bound to Plone", - long_description=( - open("README.rst").read() + "\n" + open("CHANGES.rst").read() - ), + long_description=(open("README.rst").read() + "\n" + open("CHANGES.rst").read()), classifiers=[ "Development Status :: 5 - Production/Stable", "Framework :: Plone", @@ -28,26 +26,28 @@ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ], - keywords='Plone calendar calendaring event recurring', - author='Plone Foundation', - author_email='plone-developers@lists.sourceforge.net', - url='https://github.com/plone/plone.event', - license='GPL', + keywords="Plone calendar calendaring event recurring", + author="Plone Foundation", + author_email="plone-developers@lists.sourceforge.net", + url="https://github.com/plone/plone.event", + license="GPL", packages=find_packages(), - namespace_packages=['plone'], + namespace_packages=["plone"], include_package_data=True, zip_safe=False, - python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*', + python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*", install_requires=[ - 'setuptools', - 'python-dateutil', # >4.0.2 - 'pytz', - 'zope.component', - 'zope.interface', + "setuptools", + "python-dateutil", # >4.0.2 + "pytz", + "zope.component", + "zope.interface", ], - extras_require={'test': [ - 'DateTime', - 'mock', - 'zope.configuration', - ], }, + extras_require={ + "test": [ + "DateTime", + "mock", + "zope.configuration", + ], + }, )