# Path: email_parser/reader.py
# def parse_placeholder(placeholder_str):
# def _placeholders(tree, prefix=''):
# def get_template_parts(root_path, template_filename, template_type):
# def get_inline_style(root_path, styles_names):
# def _template(root_path, tree):
# def _handle_xml_parse_error(file_path, exception):
# def _read_xml(path):
# def _read_xml_from_content(content):
# def _sort_from_template(root_path, template_filename, template_type, placeholders):
# def create_email_content(root_path, template_name, styles, placeholders, email_type):
# def get_global_placeholders(root_path, locale):
# def get_inferred_placeholders(meta_placeholders, placeholders):
# def read_from_content(root_path, email_content, locale):
# def read(root_path, email):
# def get_email_type(root_path, email):


import os.path
from unittest import TestCase
from unittest.mock import patch
from lxml import etree
from email_parser import reader
from email_parser.model import *
        """
        self.globals_xml = etree.fromstring("""
        <resources>
            <string name="content">dummy global</string>
            <string name="order" type="attribute">asc</string>
        </resources>
        """)
        self.template_str = '<html><head></head><body>{{content}}{{global_content}}</body></html>'

        self.patch_parse = patch('email_parser.reader.etree.parse')
        self.mock_parse = self.patch_parse.start()
        self.mock_parse.return_value = etree.ElementTree(self.globals_xml).getroot()

        self.patch_fs = patch('email_parser.reader.fs')
        self.mock_fs = self.patch_fs.start()
        self.mock_fs.read_file.return_value = 'test'

    def tearDown(self):
        super().tearDown()
        self.patch_fs.stop()
        self.patch_parse.stop()

    def test_template(self):
        self.mock_fs.read_file.side_effect = iter([self.email_content, self.template_str, 'test'])
        expected_placeholders = {
            'content': MetaPlaceholder('content'),
            'global_content': MetaPlaceholder('global_content')
        }
        expected_template = Template('dummy_template.html', ['dummy_template.css'], '<style>test</style>',
                                     self.template_str, expected_placeholders, EmailType.transactional.value)

# Path: email_parser/reader.py
# def parse_placeholder(placeholder_str):
# def _placeholders(tree, prefix=''):
# def get_template_parts(root_path, template_filename, template_type):
# def get_inline_style(root_path, styles_names):
# def _template(root_path, tree):
# def _handle_xml_parse_error(file_path, exception):
# def _read_xml(path):
# def _read_xml_from_content(content):
# def _sort_from_template(root_path, template_filename, template_type, placeholders):
# def create_email_content(root_path, template_name, styles, placeholders, email_type):
# def get_global_placeholders(root_path, locale):
# def get_inferred_placeholders(meta_placeholders, placeholders):
# def read_from_content(root_path, email_content, locale):
# def read(root_path, email):
# def get_email_type(root_path, email):


# Path: tests/test_reader.py
import os.path
from unittest import TestCase
from unittest.mock import patch
from lxml import etree
from email_parser import reader
from email_parser.model import *

        """
        self.globals_xml = etree.fromstring("""
        <resources>
            <string name="content">dummy global</string>
            <string name="order" type="attribute">asc</string>
        </resources>
        """)
        self.template_str = '<html><head></head><body>{{content}}{{global_content}}</body></html>'

        self.patch_parse = patch('email_parser.reader.etree.parse')
        self.mock_parse = self.patch_parse.start()
        self.mock_parse.return_value = etree.ElementTree(self.globals_xml).getroot()

        self.patch_fs = patch('email_parser.reader.fs')
        self.mock_fs = self.patch_fs.start()
        self.mock_fs.read_file.return_value = 'test'

    def tearDown(self):
        super().tearDown()
        self.patch_fs.stop()
        self.patch_parse.stop()

    def test_template(self):
        self.mock_fs.read_file.side_effect = iter([self.email_content, self.template_str, 'test'])
        expected_placeholders = {
            'content': MetaPlaceholder('content'),
            'global_content': MetaPlaceholder('global_content')
        }
        expected_template = Template('dummy_template.html', ['dummy_template.css'], '<style>test</style>',
                                     self.template_str, expected_placeholders, EmailType.transactional.value)

        template, _ = reader.read('.', self.email)