Skip to content

Commit 092f778

Browse files
committed
🎨 re-structure the repo for release
1 parent 41ad13c commit 092f778

File tree

7 files changed

+20
-110
lines changed

7 files changed

+20
-110
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ name = 'pypi'
77
python_version= '3.6'
88

99
[packages]
10+
pybars3 = "*"

moban_handlebars/engine.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import codecs
22

3-
from lml.plugin import PluginInfo
4-
53
import moban.utils as utils
6-
import moban.constants as constants
74
from pybars import Compiler
85

96

10-
@PluginInfo(constants.TEMPLATE_ENGINE_EXTENSION, tags=["handlebars", "hbs"])
117
class EngineHandlebars(object):
128
def __init__(self, template_dirs):
139
self.template_dirs = template_dirs

requirements.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
nose
2-
codecov
3-
coverage
4-
mock
5-
flake8
6-
moban
7-
black;python_version>="3.6"
8-
isort;python_version>="3.6"
1+
pybars3

rnd_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/moremoban/moban/archive/dev.zip

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from setuptools import Command, setup, find_packages
1010

11-
from platform import python_implementation
1211
PY2 = sys.version_info[0] == 2
1312
PY26 = PY2 and sys.version_info[1] < 7
1413

@@ -40,12 +39,14 @@
4039
]
4140

4241
INSTALL_REQUIRES = [
42+
'pybars3',
4343
]
4444
SETUP_COMMANDS = {}
4545

4646

4747
PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests'])
48-
EXTRAS_REQUIRE = {}
48+
EXTRAS_REQUIRE = {
49+
}
4950
# You do not need to read beyond this line
5051
PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format(
5152
sys.executable)

tests/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ mock
33
codecov
44
coverage
55
flake8
6+
moban
7+
black;python_version>="3.6"
8+
isort;python_version>="3.6"

tests/test_handlebar_engine.py

Lines changed: 11 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,25 @@
11
import os
22

3-
from lml.plugin import PluginInfo
3+
from nose.tools import eq_
4+
from moban.plugins import ENGINES, BaseEngine
5+
from moban_handlebars.engine import EngineHandlebars
46

5-
import moban.exceptions as exceptions
6-
from mock import patch
7-
from nose.tools import eq_, raises
8-
from moban.plugins import (
9-
ENGINES,
10-
Context,
11-
BaseEngine,
12-
expand_template_directories,
13-
)
14-
from moban.jinja2.engine import Engine
15-
from moban.engine_handlebars import EngineHandlebars
167

17-
18-
@PluginInfo("library", tags=["testmobans"])
19-
class TestPypkg:
20-
def __init__(self):
21-
__package_path__ = os.path.dirname(__file__)
22-
self.resources_path = os.path.join(__package_path__, "fixtures")
23-
24-
25-
def test_expand_pypi_dir():
26-
dirs = list(expand_template_directories("testmobans:template-tests"))
27-
for directory in dirs:
28-
assert os.path.exists(directory)
29-
30-
31-
@patch("moban.utils.get_moban_home", return_value="/user/home/.moban/repos")
32-
@patch("os.path.exists", return_value=True)
33-
def test_expand_repo_dir(_, __):
34-
dirs = list(expand_template_directories("git_repo:template"))
35-
36-
expected = ["/user/home/.moban/repos/git_repo/template"]
37-
eq_(expected, dirs)
38-
39-
40-
def test_default_template_type():
41-
engine = ENGINES.get_engine("jj2", [], "")
42-
assert engine.engine_cls == Engine
8+
def test_handlebars_template_not_found():
9+
path = os.path.join("tests", "fixtures", "handlebars_tests")
10+
engine = EngineHandlebars([path])
11+
template = engine.get_template("file_tests.template")
12+
data = dict(test="here")
13+
result = engine.apply_template(template, data, None)
14+
expected = "here"
15+
eq_(expected, result)
4316

4417

4518
def test_handlebars_template_type():
4619
engine = ENGINES.get_engine("hbs", [], "")
4720
assert engine.engine_cls == EngineHandlebars
4821

4922

50-
def test_default_mako_type(): # fake mako
51-
engine = ENGINES.get_engine("mako", [], "")
52-
assert engine.engine_cls.__name__ == "MakoEngine"
53-
54-
55-
@raises(exceptions.NoThirdPartyEngine)
56-
def test_unknown_template_type():
57-
ENGINES.get_engine("unknown_template_type", [], "")
58-
59-
60-
@raises(exceptions.DirectoryNotFound)
61-
def test_non_existent_tmpl_directries():
62-
BaseEngine("abc", "tests", Engine)
63-
64-
65-
@raises(exceptions.DirectoryNotFound)
66-
def test_non_existent_config_directries():
67-
BaseEngine("tests", "abc", Engine)
68-
69-
70-
@raises(exceptions.DirectoryNotFound)
71-
def test_non_existent_ctx_directries():
72-
Context(["abc"])
73-
74-
75-
def test_file_tests():
76-
output = "test.txt"
77-
path = os.path.join("tests", "fixtures", "jinja_tests")
78-
engine = BaseEngine([path], path, Engine)
79-
engine.render_to_file("file_tests.template", "file_tests.yml", output)
80-
with open(output, "r") as output_file:
81-
content = output_file.read()
82-
eq_(content, "yes\nhere")
83-
os.unlink(output)
84-
85-
8623
def test_handlebars_file_tests():
8724
output = "test.txt"
8825
path = os.path.join("tests", "fixtures", "handlebars_tests")
@@ -92,25 +29,3 @@ def test_handlebars_file_tests():
9229
content = output_file.read()
9330
eq_(content, "here")
9431
os.unlink(output)
95-
96-
97-
def test_global_template_variables():
98-
output = "test.txt"
99-
path = os.path.join("tests", "fixtures", "globals")
100-
engine = BaseEngine([path], path, Engine)
101-
engine.render_to_file("variables.template", "variables.yml", output)
102-
with open(output, "r") as output_file:
103-
content = output_file.read()
104-
eq_(content, "template: variables.template\ntarget: test.txt\nhere")
105-
os.unlink(output)
106-
107-
108-
def test_nested_global_template_variables():
109-
output = "test.txt"
110-
path = os.path.join("tests", "fixtures", "globals")
111-
engine = BaseEngine([path], path, Engine)
112-
engine.render_to_file("nested.template", "variables.yml", output)
113-
with open(output, "r") as output_file:
114-
content = output_file.read()
115-
eq_(content, "template: nested.template\ntarget: test.txt\nhere")
116-
os.unlink(output)

0 commit comments

Comments
 (0)