#!/usr/bin/env python
# coding=utf-8
from __future__ import unicode_literals

from nose.tools import eq_, raises
from pyecharts.template import ensure_echarts_is_in_the_front


def test_echarts_postion_in_dependency_list():
    test_sequence = set(['guangdong', 'shanghai', 'echarts'])
    result = ensure_echarts_is_in_the_front(test_sequence)
    eq_(result[0], 'echarts')


def test_echarts_postion_with_one_element_set():
    test_sequence = set(['echarts'])
    result = ensure_echarts_is_in_the_front(test_sequence)
    eq_(result[0], 'echarts')


@raises(Exception)
def test_echarts_postion_with_nothing():
    test_sequence = set()
    ensure_echarts_is_in_the_front(test_sequence)

@@ -71,16 +71,51 @@
 terals%0A%0A
+from mock import patch, MagicMock%0A%0A
 from nos
@@ -698,28 +698,687 @@
 in_the_front(test_sequence)%0A
+%0A%0A@patch('pyecharts.template.create_builtin_template_engine')%0Adef test_template_render(fake_creator):%0A    fake_render = MagicMock(%0A        return_value='OK'%0A    )%0A    fake_get_template = MagicMock(%0A        return_value=MagicMock(%0A            render=fake_render%0A        )%0A    )%0A    fake_env = MagicMock(%0A        get_template=fake_get_template%0A    )%0A    fake_creator.return_value = fake_env%0A%0A    from pyecharts.template import render%0A%0A    test_pills = dict(canIGet='The Pills Back',%0A                      orCanINot='Get them back')%0A    render('tmp', **test_pills)%0A    fake_get_template.assert_called_with('tmp')%0A    fake_render.assert_called_with(**test_pills)%0A

test template.render()