# -*- coding: utf-8 -*- import pytest import dingguo.parser.mytaxi 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', 'mytaxi') @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.mytaxi.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)