|
@@ -9,7 +9,7 @@ project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
|
|
script_path = os.path.join(project_root_path, 'scripts', 'order-confirmation-mail-parser')
|
|
script_path = os.path.join(project_root_path, 'scripts', 'order-confirmation-mail-parser')
|
|
test_data_path = os.path.join(project_root_path, 'tests', 'data')
|
|
test_data_path = os.path.join(project_root_path, 'tests', 'data')
|
|
|
|
|
|
-def test_integration():
|
|
+def test_integration_stdin():
|
|
for mail_path in glob.glob(os.path.join(test_data_path, '*', 'mail_*.eml')):
|
|
for mail_path in glob.glob(os.path.join(test_data_path, '*', 'mail_*.eml')):
|
|
with open(mail_path, 'r') as mail_file:
|
|
with open(mail_path, 'r') as mail_file:
|
|
process = subprocess.Popen([script_path], stdin = subprocess.PIPE, stdout = subprocess.PIPE)
|
|
process = subprocess.Popen([script_path], stdin = subprocess.PIPE, stdout = subprocess.PIPE)
|
|
@@ -18,3 +18,20 @@ def test_integration():
|
|
with open(mail_path.replace('.eml', '.yml'), 'r') as expected_result_file:
|
|
with open(mail_path.replace('.eml', '.yml'), 'r') as expected_result_file:
|
|
expected_result = yaml.load(expected_result_file.read())
|
|
expected_result = yaml.load(expected_result_file.read())
|
|
assert result == expected_result, 'unexpected result for ' + os.path.basename(mail_path)
|
|
assert result == expected_result, 'unexpected result for ' + os.path.basename(mail_path)
|
|
|
|
+
|
|
|
|
+def test_ingegration_path():
|
|
|
|
+ result = yaml.load(subprocess.check_output([
|
|
|
|
+ script_path,
|
|
|
|
+ os.path.join(test_data_path, 'amazon', 'mail_1.eml'),
|
|
|
|
+ os.path.join(test_data_path, 'oebb', 'mail_1.eml'),
|
|
|
|
+ os.path.join(test_data_path, 'oebb', 'mail_2.eml'),
|
|
|
|
+ ]))
|
|
|
|
+ expected_result = []
|
|
|
|
+ for result_path in [
|
|
|
|
+ os.path.join(test_data_path, 'amazon', 'mail_1.yml'),
|
|
|
|
+ os.path.join(test_data_path, 'oebb', 'mail_1.yml'),
|
|
|
|
+ os.path.join(test_data_path, 'oebb', 'mail_2.yml'),
|
|
|
|
+ ]:
|
|
|
|
+ with open(result_path) as yaml_file:
|
|
|
|
+ expected_result += yaml.load(yaml_file.read())
|
|
|
|
+ assert result == expected_result
|