# -*- coding: utf-8 -*- import pytest import dingguo.parser.indiegogo import email import glob import ioex import os import yaml project_root_path = os.path.realpath(os.path.join(__file__, '..', '..', '..')) test_data_path = os.path.join(project_root_path, 'tests', 'data', 'indiegogo') @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.indiegogo.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, \ u'\n%s' % ioex.yaml_diff(expected_orders, parsed_orders, colors = True)