Skip to content

Commit

Permalink
some PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
llazzaro committed May 16, 2015
1 parent 8baaa82 commit 1d1eeee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions schedule/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def occurrences_after(self, after=None):

class EventRelationManager(models.Manager):
'''
>>> import datetime
>>> EventRelation.objects.all().delete()
>>> CalendarRelation.objects.all().delete()
>>> data = {
Expand Down
35 changes: 17 additions & 18 deletions tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ def __create_event(self, title, start, end, cal):
'start': start,
'end': end,
'calendar': cal
})
})

def __create_recurring_event(self, title, start, end, end_recurring, rule, cal):
return Event(**{
return Event(**{
'title': title,
'start': start,
'end': end,
'end_recurring_period': end_recurring,
'rule': rule,
'calendar': cal
})
})

def test_edge_case_events(self):
cal = Calendar(name="MyCal")
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_event_get_occurrences_after(self):
rule = Rule(frequency="WEEKLY")
rule.save()

recurring_event = self.__create_recurring_event(
self.__create_recurring_event(
'Recurrent event test get_occurrence',
datetime.datetime(2008, 1, 5, 8, 0, tzinfo=pytz.utc),
datetime.datetime(2008, 1, 5, 9, 0, tzinfo=pytz.utc),
Expand All @@ -89,13 +89,13 @@ def test_event_get_occurrences_after(self):
datetime.datetime(2013, 1, 5, 8, 0, tzinfo=pytz.utc),
datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
cal
)
)
event_two = self.__create_event(
'Edge case event test two',
datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
datetime.datetime(2013, 1, 5, 12, 0, tzinfo=pytz.utc),
cal
)
)
event_one.save()
event_two.save()
occurrences_two = event_two.get_occurrences(
Expand All @@ -110,9 +110,9 @@ def test_event_get_occurrences_after(self):

self.assertEqual(0, len(occurrences_one))

def test_recurring_event_get_occurrences(self):
def test_recurring_event_get_occurrences_2(self):
cal = Calendar(name="MyCal")
rule = Rule(frequency = "WEEKLY")
rule = Rule(frequency="WEEKLY")
rule.save()

recurring_event = self.__create_recurring_event(
Expand All @@ -135,7 +135,7 @@ def test_recurring_event_get_occurrences_after(self):

cal = Calendar(name="MyCal")
cal.save()
rule = Rule(frequency = "WEEKLY")
rule = Rule(frequency="WEEKLY")
rule.save()
recurring_event= self.__create_recurring_event(
'Recurrent event test get_occurrence',
Expand All @@ -157,7 +157,7 @@ def test_recurring_event_get_occurrence(self):

cal = Calendar(name="MyCal")
cal.save()
rule = Rule(frequency = "WEEKLY")
rule = Rule(frequency="WEEKLY")
rule.save()

event = self.__create_recurring_event(
Expand All @@ -179,7 +179,7 @@ def test_prevent_type_error_when_comparing_naive_and_aware_dates(self):
# this only test if the TypeError is raised
cal = Calendar(name="MyCal")
cal.save()
rule = Rule(frequency = "WEEKLY")
rule = Rule(frequency="WEEKLY")
rule.save()

event = self.__create_recurring_event(
Expand All @@ -197,7 +197,7 @@ def test_prevent_type_error_when_comparing_naive_and_aware_dates(self):
def test_prevent_type_error_when_comparing_dates_when_tz_off(self):
cal = Calendar(name="MyCal")
cal.save()
rule = Rule(frequency = "WEEKLY")
rule = Rule(frequency="WEEKLY")
rule.save()

event = self.__create_recurring_event(
Expand All @@ -221,7 +221,6 @@ def test_event_get_ocurrence(self):
start + datetime.timedelta(hours=1),
cal)


occurrence = event.get_occurrence(start)
self.assertEqual(occurrence.start, start)

Expand All @@ -240,12 +239,11 @@ def test_occurences_after_with_no_params(self):
self.assertEqual(occurrences[0].start, start)
self.assertEqual(occurrences[0].end, start + datetime.timedelta(hours=1))


def test_occurences_with_recurrent_event_end_recurring_period_edge_case(self):

cal = Calendar(name='MyCal')

rule = Rule(frequency = "DAILY")
rule = Rule(frequency="DAILY")
rule.save()
start = timezone.now() + datetime.timedelta(days=1)
event = self.__create_recurring_event(
Expand All @@ -263,7 +261,7 @@ def test_get_for_object(self):
event_relations = list(Event.objects.get_for_object(user, 'owner', inherit=False))
self.assertEqual(len(event_relations), 0)

rule = Rule(frequency = "DAILY")
rule = Rule(frequency="DAILY")
rule.save()
cal = Calendar(name='MyCal')
cal.save()
Expand All @@ -272,7 +270,7 @@ def test_get_for_object(self):
datetime.datetime(2013, 1, 5, 8, 0, tzinfo=pytz.utc),
datetime.datetime(2013, 1, 5, 9, 0, tzinfo=pytz.utc),
cal
)
)
event.save()
events = list(Event.objects.get_for_object(user, 'owner', inherit=False))
self.assertEqual(len(events), 0)
Expand All @@ -285,7 +283,7 @@ def test_get_for_object(self):
def test_get_absolute(self):
cal = Calendar(name='MyCal')
cal.save()
rule = Rule(frequency = "DAILY")
rule = Rule(frequency="DAILY")
rule.save()
start = timezone.now() + datetime.timedelta(days=1)
event = self.__create_recurring_event(
Expand All @@ -302,6 +300,7 @@ def test_get_absolute(self):
def test_(self):
pass


class TestEventRelationManager(TestCase):

def test_get_events_for_object(self):
Expand Down

0 comments on commit 1d1eeee

Please sign in to comment.