Skip to content

Commit

Permalink
Merge pull request #1 from brad/jinja-email-templates
Browse files Browse the repository at this point in the history
soft-code the pledge amount in expectSubscribe
  • Loading branch information
Liam M authored and Liam M committed Jul 20, 2014
2 parents 600dc61 + 2218156 commit 674fa9a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions unittests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PledgeTest(BaseTest):
def setUp(self):
super(PledgeTest, self).setUp()
self.pledge = dict(
email='pika@pokedex.biz',
email=u'pik\u00E1@pokedex.biz',
phone='212-234-5432',
name=u'Pik\u00E1 Chu',
occupation=u'Pok\u00E9mon',
Expand Down Expand Up @@ -107,7 +107,7 @@ def expectSubscribe(self, phone=None, pledgePageSlug=None):
.Subscribe(email=self.pledge['email'],
first_name=u'Pik\u00E1',
last_name='Chu',
amount_cents=4200,
amount_cents=self.pledge['amountCents'],
ip_addr=None, # Not sure why this is None in unittests
time=mox.IsA(datetime.datetime),
phone=phone,
Expand Down Expand Up @@ -144,7 +144,7 @@ def testTeamTotalModel(self):
def testMailOnCreatePledge(self):
self.makeDefaultRequest()

messages = self.mail_stub.get_sent_messages(to=self.pledge["email"])
messages = self.mail_stub.get_sent_messages(to=self.pledge['email'].encode('utf-8'))
self.assertEquals(1, len(messages))
self.assertEquals(self.pledge["email"], messages[0].to)
self.assertTrue('Mayday PAC' in messages[0].sender)
Expand All @@ -157,7 +157,7 @@ def testSendToLessigOnCreateLargePledge(self):

totalStr = '$%d' % int(self.pledge["amountCents"] / 100)

messages = self.mail_stub.get_sent_messages(to="lessig@mac.com")
messages = self.mail_stub.get_sent_messages(to="lessig@mac.com")
self.assertEquals(1, len(messages))
self.assertEquals("lessig@mac.com", messages[0].to)
self.assertTrue('Mayday PAC' in messages[0].sender)
Expand All @@ -177,7 +177,7 @@ def testCreateAddsPledge(self):
self.assertEquals('charge_2468', pledge.stripe_charge_id)
self.assertEquals('rocket', pledge.team)

user = model.User.get_by_key_name('pika@pokedex.biz')
user = model.User.get_by_key_name(self.pledge['email'])

def assertEqualsSampleProperty(prop_name, actual):
self.assertEquals(self.pledge[prop_name], actual)
Expand Down Expand Up @@ -208,7 +208,7 @@ def testSubscribes(self):
self.mockery.ReplayAll()

self.app.post_json('/r/pledge', self.pledge)
user = model.User.get_by_key_name('pika@pokedex.biz')
user = model.User.get_by_key_name(self.pledge['email'])
assert user.mail_list_optin

def testSubscribeOptOut(self):
Expand All @@ -221,7 +221,7 @@ def testSubscribeOptOut(self):
self.mockery.ReplayAll()

self.app.post_json('/r/pledge', self.pledge)
user = model.User.get_by_key_name('pika@pokedex.biz')
user = model.User.get_by_key_name(self.pledge['email'])
assert not user.mail_list_optin

def testNoPhone(self):
Expand Down Expand Up @@ -401,7 +401,7 @@ def testThankTeam(self):
# pledge does get the email if are the reply_to
post_data['reply_to'] = self.pledge["email"]
resp = self.app.post('/r/thank', post_data)
messages = self.mail_stub.get_sent_messages(to=self.pledge["email"])
messages = self.mail_stub.get_sent_messages(to=self.pledge["email"].encode('utf-8'))
# 1 email sent is the created pledge
self.assertEquals(len(messages), 2)
# post response should be zero sent thank you emails
Expand All @@ -413,7 +413,7 @@ def testThankTeam(self):
post_data['reply_to'] = 'another@email.com'
# self.assertEquals(model.Pledge.all()[0].thank_you_sent_at, None)
resp = self.app.post('/r/thank', post_data)
messages = self.mail_stub.get_sent_messages(to=self.pledge["email"])
messages = self.mail_stub.get_sent_messages(to=self.pledge["email"].encode('utf-8'))
self.assertEquals(len(messages), 3)
self.assertEquals(messages[2].reply_to, post_data["reply_to"])
self.assertEquals(messages[2].subject, post_data["subject"])
Expand All @@ -425,7 +425,7 @@ def testThankTeam(self):
# make sure it isn't sent a message again when new_member is set to true
post_data['new_members'] = True
resp = self.app.post('/r/thank', post_data)
messages = self.mail_stub.get_sent_messages(to=self.pledge["email"])
messages = self.mail_stub.get_sent_messages(to=self.pledge["email"].encode('utf-8'))
self.assertEquals(len(messages), 3)
resp_data = json.loads(resp.text)
self.assertEquals(resp_data['num_emailed'], 0)
Expand All @@ -438,7 +438,7 @@ def testUserInfoNotFound(self):
def testUserInfoNoPledge(self):
self.makeDefaultRequest()
self.assertEquals(1, model.Pledge.all().count())
user = model.User.get_by_key_name('pika@pokedex.biz')
user = model.User.get_by_key_name(self.pledge['email'])
model.Pledge.all().filter('email =', user.email)[0].delete()
resp = self.app.get('/user-info/%s' % user.url_nonce, status=404)
self.assertEquals('user not found', resp.body)
Expand Down

0 comments on commit 674fa9a

Please sign in to comment.