diff --git a/tests/helpers_tests.py b/tests/helpers_tests.py index ceaa8a2a9ef219400ef6346b9fb1707d6a633618..f98f24a8e8fdff0fa75509ef0c8c7dc18a5e2239 100755 --- a/tests/helpers_tests.py +++ b/tests/helpers_tests.py @@ -145,63 +145,63 @@ TEST_CASES = { class HelpersTests(unittest.TestCase): + """ + Test using test generator + """ def __init__(self, *args, **kwargs): + """ + Initialize test + """ super(HelpersTests, self).__init__(*args, **kwargs) def test_generator(test_strings): + """ + Generate tests from test strings + + :param test_strings: to generate tests from + :return: test + """ def _test(self): + """ + Generate tests + :param self: + :return: test to run + """ for test_string in test_strings: self.assertEqual(remove_non_release_groups(test_string), TEST_RESULT) return _test -class HelpersTests2(unittest.TestCase): - @unittest.expectedFailure - def test_is_valid_language(self): - # TODO: Determine why this fails and at such a high failure % - """ - Test isValidLanguage - """ - exception_count = 0 - total = 0 - for lang in language.LANGUAGES: - total += 1 - try: - self.assertTrue(isValidLanguage(lang), lang) - except NameError: - exception_count += 1 - except Exception as error: - raise error - if exception_count > 0: - raise Exception('Language failure ratio: %s [%s/%s]' % - (100.0 * exception_count/total, exception_count, total)) - +class HelpersZipTests(unittest.TestCase): + """ + Test zip methods + """ @unittest.skip('Not yet implemented') - def test_fix_glob(self): + def test_make_zip(self): """ - Test fixGlob + Test makeZip """ pass @unittest.skip('Not yet implemented') - def test_indent_xml(self): + def test_extract_zip(self): """ - Test indentXML + Test extractZip """ pass @unittest.skip('Not yet implemented') - def test_remove_non_release_groups(self): + def test_backup_config_zip(self): """ - Test remove_non_release_groups + Test backupConfigZip """ pass @unittest.skip('Not yet implemented') - def test_is_media_file(self): + def test_restore_config_zip(self): """ - Test isMediaFile + Test restoreConfigZip """ pass @@ -212,24 +212,22 @@ class HelpersTests2(unittest.TestCase): """ pass - @unittest.skip('Not yet implemented') - def test_is_being_written(self): - """ - Test isBeingWritten - """ - pass +class HelpersDirectoryTests(unittest.TestCase): + """ + Test directory methods + """ @unittest.skip('Not yet implemented') - def test_remove_file_failed(self): + def test_make_dirs(self): """ - Test remove_file_failed + Test make_dirs """ pass @unittest.skip('Not yet implemented') - def test_find_certain_show(self): + def test_delete_empty_folders(self): """ - Test findCertainShow + Test delete_empty_folders """ pass @@ -241,72 +239,77 @@ class HelpersTests2(unittest.TestCase): pass @unittest.skip('Not yet implemented') - def test_search_db_for_show(self): + def test_get_temp_dir(self): """ - Test searchDBForShow + Test _getTempDir """ pass @unittest.skip('Not yet implemented') - def test_search_indexer_for_show_id(self): + def test_is_hidden_folder(self): """ - Test searchIndexerForShowID + Test is_hidden_folder """ pass @unittest.skip('Not yet implemented') - def test_list_media_files(self): + def test_real_path(self): """ - Test listMediaFiles + Test real_path """ pass + +class HelpersFileTests(unittest.TestCase): + """ + Test file helpers + """ @unittest.skip('Not yet implemented') - def test_copy_file(self): + def test_is_media_file(self): """ - Test copyFile + Test isMediaFile """ pass @unittest.skip('Not yet implemented') - def test_move_file(self): + def test_is_file_locked(self): """ - Test moveFile + Test isFileLocked """ pass @unittest.skip('Not yet implemented') - def test_link(self): + def test_is_being_written(self): """ - Test link + Test isBeingWritten """ pass @unittest.skip('Not yet implemented') - def test_hardlink_file(self): + def test_remove_file_failed(self): """ - Test hardlinkFile + Test remove_file_failed """ pass @unittest.skip('Not yet implemented') - def test_symlink(self): + def test_list_media_files(self): """ - Test symlink + Test listMediaFiles """ pass @unittest.skip('Not yet implemented') - def test_move_and_symlink_file(self): + def test_copy_file(self): """ - Test moveAndSymlinkFile + Test copyFile """ pass @unittest.skip('Not yet implemented') - def test_make_dirs(self): + def test_move_file(self): """ - Test make_dirs + Test moveFile """ pass @@ -318,154 +321,176 @@ class HelpersTests2(unittest.TestCase): pass @unittest.skip('Not yet implemented') - def test_delete_empty_folders(self): + def test_file_bit_filter(self): """ - Test delete_empty_folders + Test fileBitFilter """ pass @unittest.skip('Not yet implemented') - def test_file_bit_filter(self): + def test_chmod_as_parent(self): """ - Test fileBitFilter + Test chmodAsParent """ pass @unittest.skip('Not yet implemented') - def test_chmod_as_parent(self): + def test_backup_versioned_file(self): """ - Test chmodAsParent + Test backupVersionedFile """ pass @unittest.skip('Not yet implemented') - def test_fix_set_group_id(self): + def test_restore_versioned_file(self): """ - Test fixSetGroupID + Test restoreVersionedFile """ pass @unittest.skip('Not yet implemented') - def test_is_anime_in_show_list(self): + def test_verify_free_space(self): """ - Test is_anime_in_show_list + Test verify_freespace """ pass @unittest.skip('Not yet implemented') - def test_update_anime_support(self): + def test_get_disk_space_usage(self): """ - Test update_anime_support + Test getDiskSpaceUsage """ pass @unittest.skip('Not yet implemented') - def test_get_abs_no_from_season_and_ep(self): + def test_download_file(self): """ - Test get_absolute_number_from_season_and_episode + Test download_file """ pass @unittest.skip('Not yet implemented') - def test_get_all_eps_from_abs_no(self): + def test_get_size(self): """ - Test get_all_episodes_from_absolute_number + Test get_size """ pass @unittest.skip('Not yet implemented') - def test_sanitize_scene_name(self): + def test_md5_for_file(self): """ - Test sanitizeSceneName + Test md5_for_file """ pass @unittest.skip('Not yet implemented') - def test_arithmetic_eval(self): + def test_touch_file(self): """ - Test arithmeticEval + Test touchFile """ pass + +class HelpersFileLinksTests(unittest.TestCase): + """ + Test sym and hard links + """ @unittest.skip('Not yet implemented') - def test_create_https_certificates(self): + def test_link(self): """ - Test create_https_certificates + Test link """ pass @unittest.skip('Not yet implemented') - def test_backup_versioned_file(self): + def test_hardlink_file(self): """ - Test backupVersionedFile + Test hardlinkFile """ pass @unittest.skip('Not yet implemented') - def test_restore_versioned_file(self): + def test_symlink(self): """ - Test restoreVersionedFile + Test symlink """ pass @unittest.skip('Not yet implemented') - def test_try_int(self): + def test_move_and_symlink_file(self): """ - Test tryInt + Test moveAndSymlinkFile """ pass + +class HelpersEncryptionTests(unittest.TestCase): + """ + Test encryption and decryption + """ @unittest.skip('Not yet implemented') - def test_md5_for_file(self): + def test_create_https_certificates(self): """ - Test md5_for_file + Test create_https_certificates """ pass @unittest.skip('Not yet implemented') - def test_get_lan_ip(self): + def test_encrypt(self): """ - Test get_lan_ip + Test encrypt """ pass @unittest.skip('Not yet implemented') - def test_check_url(self): + def test_decrypt(self): """ - Test check_url + Test decrypt """ pass @unittest.skip('Not yet implemented') - def test_anon_url(self): + def test_generate_cookie_secret(self): """ - Test anon_url + Test generateCookieSecret """ pass + +class HelpersShowTests(unittest.TestCase): + """ + Test show methods + """ @unittest.skip('Not yet implemented') - def test_encrypt(self): + def test_find_certain_show(self): """ - Test encrypt + Test findCertainShow """ pass @unittest.skip('Not yet implemented') - def test_decrypt(self): + def test_search_db_for_show(self): """ - Test decrypt + Test searchDBForShow """ pass @unittest.skip('Not yet implemented') - def test_full_sanitize_scene_name(self): + def test_search_indexer_for_show_id(self): """ - Test full_sanitizeSceneName + Test searchIndexerForShowID """ pass @unittest.skip('Not yet implemented') - def test__check_against_names(self): + def test_is_anime_in_show_list(self): + """ + Test is_anime_in_show_list + """ + pass + + @unittest.skip('Not yet implemented') + def test_check_against_names(self): """ Test _check_against_names """ @@ -479,163 +504,193 @@ class HelpersTests2(unittest.TestCase): pass @unittest.skip('Not yet implemented') - def test_is_hidden_folder(self): + def test_validate_show(self): """ - Test is_hidden_folder + Test validateShow """ pass @unittest.skip('Not yet implemented') - def test_real_path(self): + def test_map_indexers_to_show(self): """ - Test real_path + Test mapIndexersToShow """ pass @unittest.skip('Not yet implemented') - def test_validate_show(self): + def test_get_abs_no_from_s_and_e(self): """ - Test validateShow + Test get_absolute_number_from_season_and_episode """ pass @unittest.skip('Not yet implemented') - def test_set_up_anidb_connection(self): + def test_get_all_eps_from_abs_no(self): """ - Test set_up_anidb_connection + Test get_all_episodes_from_absolute_number """ pass + +class HelpersConnectionTests(unittest.TestCase): + """ + Test connections + """ @unittest.skip('Not yet implemented') - def test_make_zip(self): + def test_get_lan_ip(self): """ - Test makeZip + Test get_lan_ip """ pass @unittest.skip('Not yet implemented') - def test_extract_zip(self): + def test_check_url(self): """ - Test extractZip + Test check_url """ pass @unittest.skip('Not yet implemented') - def test_backup_config_zip(self): + def test_anon_url(self): """ - Test backupConfigZip + Test anon_url """ pass @unittest.skip('Not yet implemented') - def test_restore_config_zip(self): + def test_set_up_anidb_connection(self): """ - Test restoreConfigZip + Test set_up_anidb_connection """ pass @unittest.skip('Not yet implemented') - def test_map_indexers_to_show(self): + def test_set_up_session(self): """ - Test mapIndexersToShow + Test _setUpSession """ pass @unittest.skip('Not yet implemented') - def test_touch_file(self): + def test_get_url(self): """ - Test touchFile + Test getURL """ pass @unittest.skip('Not yet implemented') - def test__get_temp_dir(self): + def test_generate_api_key(self): """ - Test _getTempDir + Test generateApiKey """ pass + +class HelpersMiscTests(unittest.TestCase): + """ + Test misc helper methods + """ + @unittest.expectedFailure + def test_is_valid_language(self): + # TODO: Determine why this fails and at such a high failure % + """ + Test isValidLanguage + """ + exception_count = 0 + total = 0 + for lang in language.LANGUAGES: + total += 1 + try: + self.assertTrue(isValidLanguage(lang), lang) + except NameError: + exception_count += 1 + except Exception as error: + raise error + if exception_count > 0: + raise Exception('Language failure ratio: %s [%s/%s]' % + (100.0 * exception_count/total, exception_count, total)) + @unittest.skip('Not yet implemented') - def test_code_description(self): + def test_fix_glob(self): """ - Test codeDescription + Test fixGlob """ pass @unittest.skip('Not yet implemented') - def test__set_up_session(self): + def test_indent_xml(self): """ - Test _setUpSession + Test indentXML """ pass @unittest.skip('Not yet implemented') - def test_get_url(self): + def test_remove_non_release_groups(self): """ - Test getURL + Test remove_non_release_groups """ pass @unittest.skip('Not yet implemented') - def test_download_file(self): + def test_fix_set_group_id(self): """ - Test download_file + Test fixSetGroupID """ pass @unittest.skip('Not yet implemented') - def test_get_size(self): + def test_update_anime_support(self): """ - Test get_size + Test update_anime_support """ pass @unittest.skip('Not yet implemented') - def test_generate_api_key(self): + def test_sanitize_scene_name(self): """ - Test generateApiKey + Test sanitizeSceneName """ pass @unittest.skip('Not yet implemented') - def test_remove_article(self): + def test_arithmetic_eval(self): """ - Test remove_article + Test arithmeticEval """ pass @unittest.skip('Not yet implemented') - def test_generate_cookie_secret(self): + def test_try_int(self): """ - Test generateCookieSecret + Test tryInt """ pass @unittest.skip('Not yet implemented') - def test_verify_free_space(self): + def test_full_sanitize_scene_name(self): """ - Test verify_freespace + Test full_sanitizeSceneName """ pass @unittest.skip('Not yet implemented') - def test_pretty_time_delta(self): + def test_code_description(self): """ - Test pretty_time_delta + Test codeDescription """ pass @unittest.skip('Not yet implemented') - def test_is_file_locked(self): + def test_remove_article(self): """ - Test isFileLocked + Test remove_article """ pass @unittest.skip('Not yet implemented') - def test_get_disk_space_usage(self): + def test_pretty_time_delta(self): """ - Test getDiskSpaceUsage + Test pretty_time_delta """ pass @@ -652,7 +707,3 @@ if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(HelpersTests) unittest.TextTestRunner(verbosity=2).run(SUITE) - - SUITE = unittest.TestLoader().loadTestsFromTestCase(HelpersTests2) - unittest.TextTestRunner(verbosity=2).run(SUITE) -