Exemplo n.º 1
0
 def test_host_overlapping_events(self):
     club = Venue("Berkeley City Club", "2315 Durant Avenue")
     rager = Performance("Steven Huangs's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 45))
     rave = Performance("Japanese Pop Rave",
                        rager.start_time + datetime.timedelta(minutes=10))
     club.host(rager)
     with self.assertRaises(ValueError):
         club.host(rave)
Exemplo n.º 2
0
 def test_add_overlapping_events(self):
     calendar = Calendar({94701, 94702, 94703, 94704})
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     rave = Performance("EDM Banger Rave",
                        rager.start_time + datetime.timedelta(minutes=5))
     calendar.add(rager)
     with self.assertRaises(ValueError):
         calendar.add(rave)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 def test_downvote_below_zero_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.")
     rager.register(anant)
     with self.assertRaises(ValueError):
         rager.downvote(anant)
Exemplo n.º 6
0
 def test_register(self):
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     anant = Performer("Anant Sahai", 94704, "I reenact animes.")
     self.assertTrue(anant not in rager.unapproved_performers)
     rager.register(anant)
     self.assertTrue(anant in rager.unapproved_performers)
Exemplo n.º 7
0
 def test_host(self):
     club = Venue("Berkeley City Club", "2315 Durant Avenue")
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     self.assertTrue(rager not in club.events)
     club.host(rager)
     self.assertTrue(rager in club.events)
Exemplo n.º 8
0
 def test_add(self):
     calendar = Calendar({94701, 94702, 94703, 94704})
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     self.assertEqual(calendar.size, 0)
     calendar.add(rager)
     self.assertEqual(calendar.size, 1)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 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)
Exemplo n.º 14
0
 def test_performer(self):
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     performer1 = Performer("Anant Sahai", 94704, "I reenact animes.")
     performer2 = Performer("Anant Sabai", 94704, "I reenact fiestas.")
     performer3 = Performer("Anant Sagai", 94704, "I reenact movies.")
     for performer in [performer1, performer2, performer3]:
         performer.apply_to(rager)
         rager.approve(performer)
     rager.upvote(performer2)
     self.assertEqual(rager.performer, performer2)
Exemplo n.º 15
0
 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)
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 def test_eq(self):
     rager1 = Performance("Nathan Trinkl's Birthday Bash",
                          datetime.datetime(18, 3, 16, 9, 55))
     rager2 = Performance("Nathan Trinkl's Birthday Bash",
                          datetime.datetime(18, 3, 16, 9, 55))
     self.assertEqual(rager1, rager2)
Exemplo n.º 18
0
 def test_overlaps(self):
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     rave = Performance("EDM Banger Rave",
                        rager.start_time + datetime.timedelta(minutes=5))
     self.assertTrue(rager.overlaps(rave))
Exemplo n.º 19
0
 def test_close_voting(self):
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     self.assertTrue(rager.is_accepting_votes)
     rager.close_voting()
     self.assertFalse(rager.is_accepting_votes)
Exemplo n.º 20
0
 def test_constructor(self):
     rager = Performance("Nathan Trinkl's Birthday Bash",
                         datetime.datetime(18, 3, 16, 9, 55))
     self.assertEqual(rager.name, "Nathan Trinkl's Birthday Bash")
     self.assertEqual(rager.start_time, datetime.datetime(18, 3, 16, 9, 55))
     self.assertEqual(rager.duration, 180)
Exemplo n.º 21
0
 def test_end_time(self):
     party = Performance("Balaji's Birthday Siesta",
                         datetime.datetime(18, 5, 14, 6, 15), 30)
     self.assertEqual(party.end_time, datetime.datetime(18, 5, 14, 6, 45))