Example #1
0
 def test_base_flow_backup_trash_dir_none(self):
     """テスト:設定ファイル・バックアップ&破棄ディレクトリ指定なし"""
     expected = set(self.TEST_OUTPUT_FILES)
     # テストディレクトリ初期化
     self.setting.test_directory_initialization()
     # テスト用入力ファイルの設置
     shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
     # テスト用の設定ファイルを設置
     self.setting.config_file_set(os.path.join(
         self.setting.TEST_CONFIG_FILES_DIR, "config_backup_trash_none.ini"))
     # オブジェクトの生成
     target = Photos()
     # テストターゲットの実行
     target.organize()
     # ターゲットのディクトリが空であること
     result_backup = False
     if not os.path.isdir("./photo/backup"):
         result_backup = True
     result_trash = False
     if not os.path.isdir("./photo/trash"):
         result_trash = True
     # 作成された写真の確認
     actual = set(os.listdir(self.TEST_OUTPUT_DIR))
     # 部分集合で結果を確認
     compare = expected.issuperset(actual)
     self.assertTrue(compare and result_backup and result_trash)
Example #2
0
 def test_organize_func_mosaic_value_exception(self):
     """テスト:写真整理処理例外(カスケード設置値異常)"""
     expected = "Fail to recognize the face!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(
             self.TEST_FILE_DIR,
             os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # 値が不正なの設定ファイルを設置
         self.setting.config_organize_file_set(
             os.path.join(self.setting.TEST_CONFIG_FILES_DIR,
                          self.setting.TEST_ORGANIZE_CONFIG_DIR,
                          "config_ng_val.ini"))
         # 設定のクリア
         photo.Cleaning._CONFIG = {}
         photo.Cleaning._CASCADE = {}
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_cascade_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
Example #3
0
 def test_organize_func_exception(self):
     """テスト:写真整理処理例外(設定値なし)"""
     expected = "Failed to read the configuration file!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(
             self.TEST_FILE_DIR,
             os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # 空の設定ファイルを設置
         self.setting.config_organize_file_set(
             os.path.join(self.setting.TEST_CONFIG_FILES_DIR,
                          self.setting.TEST_ORGANIZE_CONFIG_DIR,
                          "config_ng_none.ini"))
         # 設定のクリア
         photo.Cleaning._CONFIG = {}
         photo.Cleaning._CASCADE = {}
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_setting_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
Example #4
0
 def test_base_flow(self):
     """テスト:基本フローのテスト"""
     expected = set(self.TEST_OUTPUT_FILES)
     # テストディレクトリ初期化
     self.setting.test_directory_initialization()
     # テスト用入力ファイルの設置
     shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
     # オブジェクトの生成
     target = Photos()
     # テストターゲットの実行
     target.organize()
     # 作成された写真の確認
     actual = set(os.listdir(self.TEST_OUTPUT_DIR))
     # 部分集合で結果を確認
     compare = expected.issuperset(actual)
     self.assertTrue(compare)
Example #5
0
 def test_thumbnail_exception(self):
     """テスト:サムネイル処理例外"""
     expected = "It failed to create a thumbnail image!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # 空の設定ファイルを設置
         self.setting.config_file_set(os.path.join(
             self.setting.TEST_CONFIG_FILES_DIR, "config_ng_thumbnail_exception.ini"))
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_thumbnail_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)
Example #6
0
 def test_input_dir_none(self):
     """テスト:設定ファイル・入力ディレクトリ指定なし"""
     # テストディレクトリ初期化
     self.setting.test_directory_initialization()
     # テスト用入力ファイルの設置
     shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
     # テスト用の設定ファイルを設置
     self.setting.config_file_set(os.path.join(
         self.setting.TEST_CONFIG_FILES_DIR, "config_ng_input_none.ini"))
     # 設定のクリア
     photo.Cleaning._CONFIG = {}
     # オブジェクトの生成
     target = Photos()
     # テストターゲットの実行
     target.organize()
     # 出力先が空であることを確認
     result = False
     if not os.path.isdir(self.TEST_OUTPUT_DIR):
         result = True
     self.assertTrue(result)
Example #7
0
 def test_output_dir_none(self):
     """テスト:設定ファイル・出力ディレクトリ指定なし"""
     expected = "Photo organizing exception!"
     try:
         # テストディレクトリ初期化
         self.setting.test_directory_initialization()
         # テスト用入力ファイルの設置
         shutil.copytree(self.TEST_FILE_DIR, os.path.join(self.setting.INPUT_DIR, self.TEST_DIR))
         # テスト用の設定ファイルを設置
         self.setting.config_file_set(os.path.join(
             self.setting.TEST_CONFIG_FILES_DIR, "config_ng_output_none.ini"))
         # 設定のクリア
         photo.Cleaning._CONFIG = {}
         # オブジェクトの生成
         target = Photos()
         # テストターゲットの実行
         target.organize()
     except exception.Photo_exception as ex:
         actual = repr(ex)
         self.assertEqual(expected, actual)