瀏覽代碼

added integration test

Fabian Peter Hammerle 8 年之前
父節點
當前提交
f2ecc8bb4d
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      tests/test_renames_script.py

+ 20 - 0
tests/test_renames_script.py

@@ -0,0 +1,20 @@
+import pytest
+
+import os
+import glob
+import yaml
+import subprocess
+
+project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
+script_path = os.path.join(project_root_path, 'amazon-order-confirmation-mail-parser')
+test_data_path = os.path.join(project_root_path, 'tests', 'data')
+
+def test_integration():
+    for mail_path in glob.glob(os.path.join(test_data_path, 'mail_*.eml')):
+        with open(mail_path, 'r') as mail_file:
+            process = subprocess.Popen([script_path], stdin = subprocess.PIPE, stdout = subprocess.PIPE)
+            script_stdout, script_stderr = process.communicate(input = mail_file.read())
+            result = yaml.load(script_stdout)
+            with open(mail_path.replace('.eml', '.yml'), 'r') as expected_result_file:
+                expected_result = yaml.load(expected_result_file.read())
+                assert result == expected_result