# Path: email_parser/renderer.py
# def _md_to_html(text, base_url=None):
# def _split_subject(placeholders):
# def _transform_extended_tags(content):
#     def __init__(self, template, email_locale):
#     def _inline_css(self, html, css):
#     def _wrap_with_text_direction(self, html):
#     def _wrap_with_highlight(self, html, highlight):
#     def _render_placeholder(self, placeholder, variant=None, highlight=None):
#     def _concat_parts(self, subject, parts, variant):
#     def render(self, placeholders, variant=None, highlight=None):
#     def __init__(self, template, email_locale):
#     def _html_to_text(self, html):
#     def _md_to_text(self, text, base_url=None):
#     def render(self, placeholders, variant=None):
#     def render(self, placeholders, variant=None):
# def render(email_locale, template, placeholders, variant=None, highlight=None):
# class HtmlRenderer(object):
# class TextRenderer(object):
# class SubjectRenderer(object):
# 
# Path: email_parser/const.py
# SUBJECT_EXTENSION = '.subject'
# TEXT_EXTENSION = '.text'
# HTML_EXTENSION = '.html'
# CSS_EXTENSION = '.css'
# SOURCE_EXTENSION = '.xml'
# SUBJECT_PLACEHOLDER = 'subject'
# GLOBALS_EMAIL_NAME = 'global'
# GLOBALS_PLACEHOLDER_PREFIX = 'global_'
# REPO_SRC_PATH = 'src'
# PLACEHOLDERS_FILENAME = 'placeholders_config.json'
# INLINE_TEXT_PATTERN = r'\[{2}(.+)\]{2}'
# IMAGE_PATTERN = '![{}]({}/{})'
# SEGMENT_REGEX = r'\<string[^>]*>'
# SEGMENT_NAME_REGEX = r' name="([^"]+)"'
# TEXT_EMAIL_PLACEHOLDER_SEPARATOR = '\n\n'
# HTML_PARSER = 'lxml'
# LOCALE_PLACEHOLDER = '{link_locale}'
# DEFAULT_LOCALE = 'en'
# DEFAULT_WORKER_POOL = 10
# JSON_INDENT = 4
# 
# Path: email_parser/config.py
# def init(*,
#          _paths=_default_paths,
#          _pattern=_default_pattern,
#          _base_img_path=_default_base_img_path,
#          _rtl_locales=_default_rtl,
#          _lang_mappings=_default_lang_mappings):


from unittest import TestCase
from unittest.mock import patch
from email_parser.model import *
from email_parser import renderer, const, config
    def tearDown(self):
        config.init()

    def test_happy_path(self):
        placeholders = {'content1': Placeholder('content1', 'text1')}
        template = Template('dummy', [], '<style>body {}</style>', '<body>{{content1}}</body>', ['content1'], None)
        r = renderer.HtmlRenderer(template, self.email_locale)

        actual = r.render(placeholders)
        self.assertEqual('<body><p>text1</p></body>', actual)

    def test_variant(self):
        placeholders = {'content1': Placeholder('content1', 'text1', variants={'B': 'text2'})}
        template = Template('dummy', [], '<style>body {}</style>', '<body>{{content1}}</body>', ['content1'], None)
        r = renderer.HtmlRenderer(template, self.email_locale)

        actual = r.render(placeholders, variant='B')
        self.assertEqual('<body><p>text2</p></body>', actual)

    def test_empty_style(self):
        placeholders = {'content': Placeholder('content', 'dummy_content')}
        template = Template('dummy', [], '', '<body>{{content}}</body>', ['content1'], None)
        r = renderer.HtmlRenderer(template, self.email_locale)

        actual = r.render(placeholders)
        self.assertEqual('<body><p>dummy_content</p></body>', actual)

    def test_include_base_url(self):
        template = Template('dummy', [], '<style>body {}</style>', '<body>{{base_url}}</body>', ['base_url'], None)
        placeholders = {}

# Path: email_parser/renderer.py
# def _md_to_html(text, base_url=None):
# def _split_subject(placeholders):
# def _transform_extended_tags(content):
#     def __init__(self, template, email_locale):
#     def _inline_css(self, html, css):
#     def _wrap_with_text_direction(self, html):
#     def _wrap_with_highlight(self, html, highlight):
#     def _render_placeholder(self, placeholder, variant=None, highlight=None):
#     def _concat_parts(self, subject, parts, variant):
#     def render(self, placeholders, variant=None, highlight=None):
#     def __init__(self, template, email_locale):
#     def _html_to_text(self, html):
#     def _md_to_text(self, text, base_url=None):
#     def render(self, placeholders, variant=None):
#     def render(self, placeholders, variant=None):
# def render(email_locale, template, placeholders, variant=None, highlight=None):
# class HtmlRenderer(object):
# class TextRenderer(object):
# class SubjectRenderer(object):
# 
# Path: email_parser/const.py
# SUBJECT_EXTENSION = '.subject'
# TEXT_EXTENSION = '.text'
# HTML_EXTENSION = '.html'
# CSS_EXTENSION = '.css'
# SOURCE_EXTENSION = '.xml'
# SUBJECT_PLACEHOLDER = 'subject'
# GLOBALS_EMAIL_NAME = 'global'
# GLOBALS_PLACEHOLDER_PREFIX = 'global_'
# REPO_SRC_PATH = 'src'
# PLACEHOLDERS_FILENAME = 'placeholders_config.json'
# INLINE_TEXT_PATTERN = r'\[{2}(.+)\]{2}'
# IMAGE_PATTERN = '![{}]({}/{})'
# SEGMENT_REGEX = r'\<string[^>]*>'
# SEGMENT_NAME_REGEX = r' name="([^"]+)"'
# TEXT_EMAIL_PLACEHOLDER_SEPARATOR = '\n\n'
# HTML_PARSER = 'lxml'
# LOCALE_PLACEHOLDER = '{link_locale}'
# DEFAULT_LOCALE = 'en'
# DEFAULT_WORKER_POOL = 10
# JSON_INDENT = 4
# 
# Path: email_parser/config.py
# def init(*,
#          _paths=_default_paths,
#          _pattern=_default_pattern,
#          _base_img_path=_default_base_img_path,
#          _rtl_locales=_default_rtl,
#          _lang_mappings=_default_lang_mappings):


# Path: tests/test_renderer.py
from unittest import TestCase
from unittest.mock import patch
from email_parser.model import *
from email_parser import renderer, const, config

    def tearDown(self):
        config.init()

    def test_happy_path(self):
        placeholders = {'content1': Placeholder('content1', 'text1')}
        template = Template('dummy', [], '<style>body {}</style>', '<body>{{content1}}</body>', ['content1'], None)
        r = renderer.HtmlRenderer(template, self.email_locale)

        actual = r.render(placeholders)
        self.assertEqual('<body><p>text1</p></body>', actual)

    def test_variant(self):
        placeholders = {'content1': Placeholder('content1', 'text1', variants={'B': 'text2'})}
        template = Template('dummy', [], '<style>body {}</style>', '<body>{{content1}}</body>', ['content1'], None)
        r = renderer.HtmlRenderer(template, self.email_locale)

        actual = r.render(placeholders, variant='B')
        self.assertEqual('<body><p>text2</p></body>', actual)

    def test_empty_style(self):
        placeholders = {'content': Placeholder('content', 'dummy_content')}
        template = Template('dummy', [], '', '<body>{{content}}</body>', ['content1'], None)
        r = renderer.HtmlRenderer(template, self.email_locale)

        actual = r.render(placeholders)
        self.assertEqual('<body><p>dummy_content</p></body>', actual)

    def test_include_base_url(self):
        template = Template('dummy', [], '<style>body {}</style>', '<body>{{base_url}}</body>', ['base_url'], None)
        placeholders = {}

        r = renderer.HtmlRenderer(template, self.email_locale)