def songs_probably_equal_short_song_test(self): """ Test the songs_probably_equal function with a song and a shorter version of the same song. """ # GIVEN: A song and a short version of the same song. self.song1.search_lyrics = self.full_lyrics self.song2.search_lyrics = self.short_lyrics # WHEN: We compare those songs for equality. result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be True. assert result == True, 'The result should be True'
def songs_probably_equal_error_song_test(self): """ Test the songs_probably_equal function with a song and a very erroneous version of the same song. """ # GIVEN: A song and the same song with lots of errors. self.song1.search_lyrics = self.full_lyrics self.song2.search_lyrics = self.error_lyrics # WHEN: We compare those songs for equality. result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be True. assert result == True, 'The result should be True'
def songs_probably_equal_different_song_test(self): """ Test the songs_probably_equal function with two different songs. """ # GIVEN: Two different songs. self.song1.search_lyrics = self.full_lyrics self.song2.search_lyrics = self.different_lyrics # WHEN: We compare those songs for equality. result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be False. assert result == False, 'The result should be False'
def songs_probably_equal_same_song_test(self): """ Test the songs_probably_equal function with twice the same song. """ # GIVEN: Two equal songs. self.song1.search_lyrics = self.full_lyrics self.song2.search_lyrics = self.full_lyrics # WHEN: We compare those songs for equality. result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be True. assert result == True, 'The result should be True'
def songs_probably_equal_short_song_test(self): """ Test the songs_probably_equal function with a song and a shorter version of the same song. """ # GIVEN: A song and a short version of the same song. song_tuple1 = (1, self.full_lyrics) song_tuple2 = (3, self.short_lyrics) # WHEN: We compare those songs for equality. result = songs_probably_equal((song_tuple1, song_tuple2)) # THEN: The result should be a tuple.. assert result == (1, 3), 'The result should be the tuble of song positions'
def songs_probably_equal_same_song_test(self): """ Test the songs_probably_equal function with twice the same song. """ # GIVEN: Two equal songs. song_tuple1 = (2, self.full_lyrics) song_tuple2 = (4, self.full_lyrics) # WHEN: We compare those songs for equality. result = songs_probably_equal((song_tuple1, song_tuple2)) # THEN: The result should be a tuple.. assert result == (2, 4), 'The result should be the tuble of song positions'
def songs_probably_equal_different_song_test(self): """ Test the songs_probably_equal function with two different songs. """ # GIVEN: Two different songs. song_tuple1 = (5, self.full_lyrics) song_tuple2 = (8, self.different_lyrics) # WHEN: We compare those songs for equality. result = songs_probably_equal((song_tuple1, song_tuple2)) # THEN: The result should be None. assert result is None, 'The result should be None'
def songs_probably_equal_error_song_test(self): """ Test the songs_probably_equal function with a song and a very erroneous version of the same song. """ # GIVEN: A song and the same song with lots of errors. song_tuple1 = (4, self.full_lyrics) song_tuple2 = (7, self.error_lyrics) # WHEN: We compare those songs for equality. result = songs_probably_equal((song_tuple1, song_tuple2)) # THEN: The result should be a tuple of song positions. assert result == (4, 7), 'The result should be the tuble of song positions'
def custom_page_changed(self, page_id): """ Called when changing the wizard page. ``page_id`` ID of the page the wizard changed to. """ # Hide back button. self.button(QtGui.QWizard.BackButton).hide() if page_id == self.searching_page_id: self.application.set_busy_cursor() try: self.button(QtGui.QWizard.NextButton).hide() # Search duplicate songs. max_songs = self.plugin.manager.get_object_count(Song) if max_songs == 0 or max_songs == 1: self.duplicate_search_progress_bar.setMaximum(1) self.duplicate_search_progress_bar.setValue(1) self.notify_no_duplicates() return # With x songs we have x*(x - 1) / 2 comparisons. max_progress_count = max_songs * (max_songs - 1) // 2 self.duplicate_search_progress_bar.setMaximum(max_progress_count) songs = self.plugin.manager.get_all_objects(Song) for outer_song_counter in range(max_songs - 1): for inner_song_counter in range(outer_song_counter + 1, max_songs): if songs_probably_equal(songs[outer_song_counter], songs[inner_song_counter]): duplicate_added = self.add_duplicates_to_song_list(songs[outer_song_counter], songs[inner_song_counter]) if duplicate_added: self.found_duplicates_edit.appendPlainText(songs[outer_song_counter].title + " = " + songs[inner_song_counter].title) self.duplicate_search_progress_bar.setValue(self.duplicate_search_progress_bar.value() + 1) # The call to process_events() will keep the GUI responsive. self.application.process_events() if self.break_search: return self.review_total_count = len(self.duplicate_song_list) if self.review_total_count == 0: self.notify_no_duplicates() else: self.button(QtGui.QWizard.NextButton).show() finally: self.application.set_normal_cursor() elif page_id == self.review_page_id: self.process_current_duplicate_entry()