123456789101112131415161718192021222324 |
- # -*- coding: utf-8 -*-
- import pytest
- import dingguo.parser.wienerlinien
- import email
- import glob
- import os
- import test_yaml
- import yaml
- project_root_path = os.path.realpath(os.path.join(__file__, '..', '..'))
- test_data_path = os.path.join(project_root_path, 'tests', 'data', 'wienerlinien')
- @pytest.mark.parametrize('mail_path', glob.glob(os.path.join(test_data_path, '*.eml')))
- def test_parse_confirmation_mail(mail_path):
- with open(mail_path) as mail:
- parsed_orders = dingguo.parser.wienerlinien.parse_order_confirmation_mail(
- email.message_from_file(mail)
- )
- with open(mail_path.replace('.eml', '.yml')) as yaml_file:
- expected_orders = yaml.load(yaml_file.read())
- assert expected_orders == parsed_orders, \
- test_yaml.yaml_diff(expected_orders, parsed_orders)
|