-
Notifications
You must be signed in to change notification settings - Fork 4
/
tests.py
39 lines (28 loc) · 1.14 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import unittest
from boilerplate import cmdline
class CommandLineHandlerTest(unittest.TestCase):
def setUp(self):
self.handler = cmdline.Handler(
stdout = StringIO(),
stderr = StringIO(),
)
def test_it_fails_when_no_arguments_or_options_applied(self):
self.handler.handle([])
msg = self.handler.stderr.getvalue()
assert msg.startswith("There's no enough arguments"), "Wrong message | %s" % msg
def test_it_fails_then_theres_no_enougth_arguments(self):
template_name = "boil_template" # standard template, always exists
args = [template_name]
self.handler.handle(args)
msg = self.handler.stderr.getvalue()
assert msg.startswith("Please add project name"), "Wrong message | %s" % msg
def test_it_should_have_at_least_one_default_template(self):
res = self.handler.get_templates_list()
assert len(res) >= 1, "There should be at least one template by default."
if __name__ == '__main__':
unittest.main()