Skip to content

Commit

Permalink
rename vars and refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jdupl committed Jan 14, 2016
1 parent 2c78e5b commit 5c080d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions python/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ def _split_line(self, string):
return parts

def _get_modifiers_as_string(self, string):
"""Returns tuple (at_end, relative_modifier, time_modifier)
"""Returns tuple (at_end, relative_modifier_str, time_modifier_str)
at_end: True if the modifiers should be applied to the end of the
event. False if the modifiers should be applied to the start
of the event.
relative_modifier: The delta to apply to the event start or end as a
relative_modifier_str: The delta to apply to the event start or end as a
string. Supports +/- d/h/m for days, hours, minutes.
ex: '-1d', '+15m', '+4h'
time_modifier: None or a modifier of the final time as a string.
time_modifier_str: None or a modifier of the final time as a string.
Must be applied last.
ex: @23:55
"""
Expand All @@ -59,10 +59,10 @@ def _get_modifiers_as_string(self, string):
raise Exception('Invalid syntax while parsing modifiers.')

at_end = r.groupdict()['end'] == 'F'
relative_modifier = r.groupdict()['rel']
time_modifier = r.groupdict()['time']
relative_modifier_str = r.groupdict()['rel']
time_modifier_str = r.groupdict()['time']

return (at_end, relative_modifier, time_modifier)
return (at_end, relative_modifier_str, time_modifier_str)

def _interpret_time_modifier(self, time_modifier_str):
return datetime.strptime(time_modifier_str, "%H:%M").time()
Expand Down
18 changes: 9 additions & 9 deletions python/tests/interpreter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,24 @@ def test_interpret_relative_modifier(self):
self.interpreter._interpret_relative_modifier('106m'))

def test_build_new_date_from_event(self):
expected = arrow.get('1000000060').datetime
expected = arrow.get(2000, 1, 1, 0, 1).datetime
actual = self.interpreter._get_new_datetime(
arrow.get('1000000000').datetime, timedelta(minutes=1), None)
arrow.get(2000, 1, 1).datetime, timedelta(minutes=1), None)
self.assertEqual(expected, actual)

expected = arrow.get('1000000000').datetime
expected = arrow.get(2000, 1, 1).datetime
actual = self.interpreter._get_new_datetime(
arrow.get('1000000120').datetime, timedelta(minutes=-2), None)
arrow.get(2000, 1, 1, 0, 2).datetime, timedelta(minutes=-2), None)
self.assertEqual(expected, actual)

expected = arrow.get('1000010800').datetime
expected = arrow.get(2000, 1, 1, 3).datetime
actual = self.interpreter._get_new_datetime(
arrow.get('1000000000').datetime, timedelta(hours=3), None)
arrow.get(2000, 1, 1).datetime, timedelta(hours=3), None)
self.assertEqual(expected, actual)

expected = arrow.get('1000000000').datetime
expected = arrow.get(1999, 12, 31).datetime
actual = self.interpreter._get_new_datetime(
arrow.get('1000086400').datetime, timedelta(days=-1), None)
arrow.get(2000, 1, 1).datetime, timedelta(days=-1), None)
self.assertEqual(expected, actual)

expected = arrow.get(2000, 1, 1, 2, 5).datetime
Expand All @@ -232,6 +232,6 @@ def test_build_new_date_from_event(self):

expected = arrow.get(1999, 12, 31, 23, 55).datetime
actual = self.interpreter._get_new_datetime(
arrow.get(2000, 1, 1, 0, 0).datetime, timedelta(days=-1),
arrow.get(2000, 1, 1).datetime, timedelta(days=-1),
time(hour=23, minute=55))
self.assertEqual(expected, actual)

0 comments on commit 5c080d0

Please sign in to comment.