Example #1
0
 def test_clinton_in_leans_clinton(self):
     user = UserFactory(
         profile__preferred_candidate=CANDIDATE_CLINTON,
         profile__state=self.lean_clinton.name)
     ctx = ProfileContext(user.profile)
     self.assertFalse(ctx.needs_match)
     self.assertFalse(ctx.kingmaker)
     self.assertFalse(ctx.third_party)
Example #2
0
 def test_stein_in_safe_trump(self):
     user = UserFactory(
         profile__preferred_candidate=CANDIDATE_STEIN,
         profile__state=self.safe_trump.name)
     ctx = ProfileContext(user.profile)
     self.assertFalse(ctx.needs_match)
     self.assertFalse(ctx.kingmaker)
     self.assertTrue(ctx.third_party)
Example #3
0
 def test_johnson_in_leans_trump(self):
     user = UserFactory(
         profile__preferred_candidate=CANDIDATE_JOHNSON,
         profile__state=self.lean_trump.name)
     ctx = ProfileContext(user.profile)
     self.assertTrue(ctx.needs_match)
     self.assertTrue(ctx.kingmaker)
     self.assertTrue(ctx.third_party)
Example #4
0
 def test_johnson_in_safe_clinton(self):
     user = UserFactory(
         profile__preferred_candidate=CANDIDATE_JOHNSON,
         profile__state=self.safe_clinton.name)
     ctx = ProfileContext(user.profile)
     self.assertFalse(ctx.needs_match)
     self.assertFalse(ctx.kingmaker)
     self.assertTrue(ctx.third_party)
Example #5
0
 def test_has_proposed_to_friend(self):
     profile = ProfileFactory.create(state=self.swing_state.name)
     friend = ProfileFactory.create(state=self.safe_state.name)
     profile.friends.add(friend)
     ctx = ProfileContext(profile)
     self.assertFalse(ctx.has_proposed_to_friend(friend))
     PairProposal.objects.create(
         from_profile=profile, to_profile=friend)
     ctx = ProfileContext(profile)
     self.assertTrue(ctx.has_proposed_to_friend(friend))
Example #6
0
 def test_safe_match(self):
     # The logged in user is in a safe state, their match in a swing state
     friend = UserFactory.create(
         profile__state=self.swing_state.name,
         profile__preferred_candidate=CANDIDATE_JOHNSON)
     user = UserFactory.create(
         profile__state=self.safe_state.name,
         profile__preferred_candidate=CANDIDATE_CLINTON)
     user.profile.friends.add(friend.profile)
     profile_ctx = ProfileContext(user.profile)
     [friend_context] = profile_ctx.good_potential_matches
     self.assertTrue(
         "Will vote for %s in %s" % (
             CANDIDATE_CLINTON, self.swing_state.name)
         in friend_context.proposal_string)
     self.assertTrue(
         "your vote for %s in %s" % (
             CANDIDATE_JOHNSON, self.safe_state.name)
         in friend_context.proposal_string)