Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: handle different behavior in rotating table tests at month-end
Browse files Browse the repository at this point in the history
Two of the tests for update_rotating_tables failed to account for
a different code-path that runs at the end of the month when the
next day is a new month. This change populates the next month
message table entry so that it won't matter if its the end of
the month or not for the tests to run properly.

Closes #502
  • Loading branch information
bbangert committed Jul 13, 2016
1 parent 6c90f8d commit 1997372
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions autopush/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ def test_update_rotating_tables(self):
settings.current_month = last_month.month
settings.message_tables = {}

# Create the next month's table, just in case today is the day before
# a new month, in which case the lack of keys will cause an error in
# update_rotating_tables
next_month = get_month(1)
settings.message_tables[next_month.month] = None

# Get the deferred back
e = Deferred()
d = settings.update_rotating_tables()

def check_tables(result):
eq_(len(settings.message_tables), 1)
eq_(len(settings.message_tables), 2)
eq_(settings.current_month, get_month().month)

d.addCallback(check_tables)
d.addBoth(lambda x: e.callback(True))
Expand Down Expand Up @@ -114,18 +121,25 @@ def check_tables(result):
return d

def test_update_not_needed(self):
from autopush.db import get_month
settings = AutopushSettings(
hostname="google.com", resolve_hostname=True)

# Erase the tables it has on init, and move current month back one
settings.message_tables = {}

# Create the next month's table, just in case today is the day before
# a new month, in which case the lack of keys will cause an error in
# update_rotating_tables
next_month = get_month(1)
settings.message_tables[next_month.month] = None

# Get the deferred back
e = Deferred()
d = settings.update_rotating_tables()

def check_tables(result):
eq_(len(settings.message_tables), 0)
eq_(len(settings.message_tables), 1)

d.addCallback(check_tables)
d.addBoth(lambda x: e.callback(True))
Expand Down

0 comments on commit 1997372

Please sign in to comment.