Ejemplo n.º 1
0
 def test_music_bracket_pick_random_song(self):
     test = MusicBracket(2)
     test.add_song(self.first_song)
     test.add_song(self.second_song)
     for x in range(5):
         self.assertIn(test.pick_random_song(),
                       [self.first_song, self.second_song])
Ejemplo n.º 2
0
 def test_music_bracket_add_wildcard_to_songs_double_wildcard(self):
     test = MusicBracket(2)
     test.add_wildcard(self.first_song)
     test.add_wildcard(self.second_song)
     test.move_wildcard_to_songs()
     self.assertEqual(len(test.wildcard_songs), 1)
     self.assertEqual(len(test.wildcard_songs), 1)
Ejemplo n.º 3
0
 def test_music_bracket_get_bracket(self):
     test = MusicBracket(2)
     test.add_song(self.first_song)
     test.add_song(self.second_song)
     test.create_bracket()
     self.assertIn(test.get_bracket(), [
         str(Bracket(self.first_song, self.second_song, 1)) + '\n',
         str(Bracket(self.second_song, self.first_song, 1)) + '\n'
     ])
Ejemplo n.º 4
0
 def test_music_bracket_create_bracket(self):
     test = MusicBracket(2)
     test.add_song(self.first_song)
     test.add_song(self.second_song)
     test.create_bracket()
     self.assertIn(str(test.bracket), [
         str([Bracket(self.second_song, self.first_song, 1)]),
         str([Bracket(self.first_song, self.second_song, 1)])
     ])
Ejemplo n.º 5
0
 def test_music_bracket_dictionary_output(self):
     test = MusicBracket(4)
     test.add_song(self.first_song)
     test.add_song(self.second_song)
     test.add_wildcard(self.third_song)
     test.add_wildcard(self.forth_song)
     self.assertEqual(
         test.output(),
         dict(Songs=[self.first_song, self.second_song],
              Wildcard_Songs=[self.third_song, self.forth_song],
              Bracket_Size=4))
Ejemplo n.º 6
0
    def test_music_bracket_create_double_bracket(self):
        test = MusicBracket(2)
        test.add_song(self.first_song)
        test.add_song(self.second_song)
        test.create_bracket()
        with self.assertRaises(Exception):
            test.create_bracket()

        test.add_song(self.third_song)
        test.add_song(self.forth_song)
        with self.assertRaises(Exception):
            test.create_bracket()
Ejemplo n.º 7
0
    def test_music_bracket_promote_none_bracket(self):
        test = MusicBracket(2)
        with self.assertRaises(IndexError):
            test.promote()

        test.add_song(self.first_song)
        test.add_song(self.second_song)
        with self.assertRaises(IndexError):
            test.promote()

        test.create_bracket()
        with self.assertRaises(IndexError):
            test.promote()
Ejemplo n.º 8
0
    def test_music_bracket_promote_none_winner(self):
        test = MusicBracket(4)
        test.add_song(self.first_song)
        test.add_song(self.second_song)
        test.add_song(self.third_song)
        test.add_song(self.forth_song)
        test.create_bracket()

        with self.assertRaises(ValueError):
            test.promote()

        test.vote(0, 1, 2)
        with self.assertRaises(ValueError):
            test.promote()
Ejemplo n.º 9
0
    def test_music_bracket_vote(self):
        test = MusicBracket(2)
        test.add_song(self.first_song)
        test.add_song(self.second_song)
        test.create_bracket()

        test.vote(0, 1, 2)
        self.assertEqual(test.bracket[0].song_b, test.bracket[0].winner)

        test.vote(0, 2, 1)
        self.assertEqual(test.bracket[0].song_a, test.bracket[0].winner)

        test.vote(0, 1, 1)
        self.assertIn(test.bracket[0].winner,
                      [self.first_song, self.second_song])
Ejemplo n.º 10
0
 def test_music_bracket_promote(self):
     test = MusicBracket(4)
     test.add_song(self.first_song)
     test.add_song(self.second_song)
     test.add_song(self.third_song)
     test.add_song(self.forth_song)
     test.create_bracket()
     test.vote(0, 2, 1)
     test.vote(1, 2, 1)
     test.promote()
     self.assertEqual(test.bracket.__len__(), 3)
     self.assertIn(test.bracket[2].song_a, [
         self.first_song, self.second_song, self.third_song, self.forth_song
     ])
     self.assertIn(test.bracket[2].song_b, [
         self.first_song, self.second_song, self.third_song, self.forth_song
     ])
     self.assertNotEqual(test.bracket[2].song_a, test.bracket[2].song_b)
Ejemplo n.º 11
0
    def standard_bracket():
        song1 = Song("Dragonball Durag", "Thundercat")
        song2 = Song("In Too Deep", "Eminem")
        song3 = Song("I Won't Be Home for Christmas", "Poppy")
        song4 = Song("Heat Waves", "Glass Animals")
        song5 = Song("All I Need", "Jacob Collier")
        song6 = Song("Better - Radio Edit", "Jack Garratt")
        song7 = Song("Draw the Line", "David Larbi")
        song8 = Song("Revenge", "Joyner Lucas")
        song9 = Song("Break My Heart Again", "Finneas")
        song10 = Song("My Agenda", "Dorian Electra")
        song11 = Song("Let's Fall in Love for the Night", "Finneas")
        song12 = Song("The Lighthouse Keeper", "Sam Smith")
        song13 = Song("Run", "Joji")
        song14 = Song("Leave Me Alone", "I DON'T KNOW HOW BUT THEY FOUND ME")
        song15 = Song("Bad Friend", "Rina Sawayama")

        wildcard1 = Song("Mr Experience", "Donny Benet")
        wildcard2 = Song("The Hungry Wolf of Fate",
                         "King Gizzard & The Lizzard Wizard")
        wildcard3 = Song("Without Me", "Halsey")
        wildcard4 = Song("You Should Be Sad", "Halsey")
        wildcard5 = Song("That Won't Save Us", "Against The Current")

        test_music_draft = MusicBracket(16)
        test_music_draft.add_song(song1)
        test_music_draft.add_song(song2)
        test_music_draft.add_song(song3)
        test_music_draft.add_song(song4)
        test_music_draft.add_song(song5)
        test_music_draft.add_song(song6)
        test_music_draft.add_song(song7)
        test_music_draft.add_song(song8)
        test_music_draft.add_song(song9)
        test_music_draft.add_song(song10)
        test_music_draft.add_song(song11)
        test_music_draft.add_song(song12)
        test_music_draft.add_song(song13)
        test_music_draft.add_song(song14)
        test_music_draft.add_song(song15)

        test_music_draft.add_wildcard(wildcard1)
        test_music_draft.add_wildcard(wildcard2)
        test_music_draft.add_wildcard(wildcard3)
        test_music_draft.add_wildcard(wildcard4)
        test_music_draft.add_wildcard(wildcard5)

        test_music_draft.create_bracket()

        for x in range(8):
            test_music_draft.vote(x, 3, 2)

        for x in range(4):
            test_music_draft.promote()

        for x in range(8, 12):
            test_music_draft.vote(x, 2, 3)

        for x in range(2):
            test_music_draft.promote()

        for x in range(12, 14):
            test_music_draft.vote(x, 2, 3)

        for x in range(1):
            test_music_draft.promote()

        test_music_draft.vote(14, 3, 3)
Ejemplo n.º 12
0
 def test_music_bracket_vote_none_bracket(self):
     test = MusicBracket(2)
     with self.assertRaises(IndexError):
         test.vote(0, 1, 1)
Ejemplo n.º 13
0
 def test_music_bracket_get_empty_bracket(self):
     test = MusicBracket(2)
     with self.assertRaises(ValueError):
         test.create_bracket()
Ejemplo n.º 14
0
 def test_music_bracket_add_wildcard_to_songs(self):
     test = MusicBracket(2)
     test.add_wildcard(self.first_song)
     test.move_wildcard_to_songs()
     self.assertEqual(test.wildcard_songs, [])
     self.assertEqual(test.songs, [self.first_song])
Ejemplo n.º 15
0
 def test_music_bracket_add_wildcard(self):
     test = MusicBracket(2)
     test.add_wildcard(self.first_song)
     test.add_wildcard(self.second_song)
     self.assertEqual(test.wildcard_songs,
                      [self.first_song, self.second_song])
Ejemplo n.º 16
0
 def test_music_bracket_creation(self):
     for i in range(10):
         MusicBracket(2**(i + 1))