# Path: statik/utils.py
# def add_url_path_component(path, component):
#     return '%s/%s' % (path.rstrip('/'), component.lstrip('/'))
# 
# Path: statik/filters.py
# @register.filter(name="date")
# def filter_datetime(value, format="%Y-%m-%d %H:%M:%S"):
#     return value.strftime(format)


import os.path
import unittest
import xml.etree.ElementTree as ET
from statik.views import *
from statik.utils import add_url_path_component
from statik.filters import filter_datetime
from statik.templating import *
from jinja2 import Environment, DictLoader
      <title>Sample post</title>
      <link>http://somewhere.com/2016/02/24/some-post/</link>
      <pubDate>Wed, 24 Feb 2016 11:12:41 +0200</pubDate>
      <guid>http://somewhere.com/2016/02/24/some-post/</guid>
    </item>
  </channel>
</rss>
"""
}

TEST_XML_VIEW = """path: /index.xml
template: rss.xml
context:
  static:
    feed-title: My RSS Feed
"""


class MockStatikJinjaTemplateProvider(StatikTemplateProvider):

    def __init__(self, templates_dict=TEST_TEMPLATES, base_path="/"):
        self.env = Environment(
            loader=DictLoader(templates_dict),
            extensions=[
                'statik.jinja2ext.StatikUrlExtension',
                'statik.jinja2ext.StatikAssetExtension'
            ]
        )
        self.env.filters['date'] = filter_datetime
        self.env.statik_base_url = base_path

# Path: statik/utils.py
# def add_url_path_component(path, component):
#     return '%s/%s' % (path.rstrip('/'), component.lstrip('/'))
# 
# Path: statik/filters.py
# @register.filter(name="date")
# def filter_datetime(value, format="%Y-%m-%d %H:%M:%S"):
#     return value.strftime(format)


# Path: tests/modular/test_jinja2_views.py
import os.path
import unittest
import xml.etree.ElementTree as ET
from statik.views import *
from statik.utils import add_url_path_component
from statik.filters import filter_datetime
from statik.templating import *
from jinja2 import Environment, DictLoader

      <title>Sample post</title>
      <link>http://somewhere.com/2016/02/24/some-post/</link>
      <pubDate>Wed, 24 Feb 2016 11:12:41 +0200</pubDate>
      <guid>http://somewhere.com/2016/02/24/some-post/</guid>
    </item>
  </channel>
</rss>
"""
}

TEST_XML_VIEW = """path: /index.xml
template: rss.xml
context:
  static:
    feed-title: My RSS Feed
"""


class MockStatikJinjaTemplateProvider(StatikTemplateProvider):

    def __init__(self, templates_dict=TEST_TEMPLATES, base_path="/"):
        self.env = Environment(
            loader=DictLoader(templates_dict),
            extensions=[
                'statik.jinja2ext.StatikUrlExtension',
                'statik.jinja2ext.StatikAssetExtension'
            ]
        )
        self.env.filters['date'] = filter_datetime
        self.env.statik_base_url = base_path

        self.env.statik_base_asset_url = add_url_path_component(