def test_vote_unapproved_performer_raises_exception(self): rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) anant = Performer("Anant Sahai", 94704, "I reenact animes.") anant.apply_to(rager) with self.assertRaises(ValueError): rager.upvote(anant)
def test_apply_to(self): anant = Performer("Anant Sahai", 94704, "I reenact anime.") rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) self.assertTrue(anant not in rager.unapproved_performers) anant.apply_to(rager) self.assertTrue(anant in rager.unapproved_performers)
def test_approve_for_not_hosted_event(self): club = Venue("Berkeley City Club", "2315 Durant Avenue") anant = Performer("Anant Sahai", 94704, "I reenact animes.") rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) anant.apply_to(rager) with self.assertRaises(ValueError): club.approve(anant, rager)
def test_num_votes(self): rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) anant = Performer("Anant Sahai", 94704, "I reenact animes.") anant.apply_to(rager) rager.approve(anant) rager.upvote(anant) self.assertEqual(rager.num_votes(anant), 1)
def test_approve(self): club = Venue("Berkeley City Club", "2315 Durant Avenue") anant = Performer("Anant Sahai", 94704, "I reenact animes.") rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) club.host(rager) anant.apply_to(rager) self.assertTrue(anant not in rager.approved_performers) club.approve(anant, rager) self.assertTrue(anant in rager.approved_performers)
def test_vote_increments_num_votes(self): john = Consumer("John DeNero", 94704) anant = Performer("Anant Sahai", 94704, "I reenact anime.") rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) anant.apply_to(rager) rager.approve(anant) self.assertEqual(rager.num_votes(anant), 0) john.vote_for(anant, rager) self.assertEqual(rager.num_votes(anant), 1)
def test_approve_moves_performer(self): rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) anant = Performer("Anant Sahai", 94704, "I reenact animes.") self.assertEqual(len(rager.unapproved_performers), 0) anant.apply_to(rager) self.assertEqual(len(rager.unapproved_performers), 1) self.assertEqual(len(rager.approved_performers), 0) rager.approve(anant) self.assertEqual(len(rager.unapproved_performers), 0) self.assertEqual(len(rager.approved_performers), 1)
def test_vote_works_correctly_when_vote_changes(self): john = Consumer("John DeNero", 94704) anant = Performer("Anant Sahai", 94704, "I reenact anime.") rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) anant.apply_to(rager) rager.approve(anant) john.vote_for(anant, rager) self.assertEqual(rager.num_votes(anant), 1) paul = Performer("Paul Hilfinger", 94704, "I sing opera.") paul.apply_to(rager) rager.approve(paul) john.vote_for(paul, rager) self.assertEqual(rager.num_votes(anant), 0) self.assertEqual(rager.num_votes(paul), 1)
def test_vote_works_with_multiple_events(self): john = Consumer("John DeNero", 94704) anant = Performer("Anant Sahai", 94704, "I reenact anime.") paul = Performer("Paul Hilfinger", 94704, "I sing opera.") rager = Performance("Nathan Trinkl's Birthday Bash", datetime.datetime(18, 3, 16, 9, 55)) concert = Performance("Yanni Live at the Taj Mahal", datetime.datetime(14, 7, 24, 6, 30)) anant.apply_to(rager) paul.apply_to(concert) rager.approve(anant) concert.approve(paul) john.vote_for(anant, rager) john.vote_for(paul, concert) self.assertEqual(rager.num_votes(anant), 1) self.assertEqual(concert.num_votes(paul), 1)