-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
57 lines (47 loc) · 1.68 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
from cookiecutter import main
import subprocess
import unittest
import tempfile
import shutil
import os
class TestTemplate(unittest.TestCase):
scripts = [
'bin/bower',
'bin/django-manage',
'bin/django-serve',
]
filenames = [
'parts/wsgi/wsgi',
'project_name.egg-info/entry_points.txt',
]
def setUp(self):
self.cwd = os.getcwd()
self.tmpldir = os.path.dirname(os.path.abspath(__file__))
self.binary = os.path.join(self.tmpldir, 'bin', 'cookiecutter')
self.wd = tempfile.mkdtemp(prefix='cookiecutter')
self.addCleanup(os.chdir, self.cwd)
self.addCleanup(shutil.rmtree, self.wd)
os.chdir(self.wd)
def test_template(self):
main.cookiecutter(self.tmpldir, checkout=False, no_input=True)
os.chdir(os.path.join(self.wd, 'project_name'))
for filename in self.scripts:
self.assertTrue(os.path.isfile(filename),
filename + ' not generated')
for filename in self.filenames:
self.assertTrue(os.path.isfile(filename),
filename + ' not generated')
ret = subprocess.call(
'bin/django-manage syncdb --noinput --migrate',
shell=True)
self.assertEqual(ret, 0)
tox = os.path.join(self.cwd, 'bin', 'tox')
if not os.path.isfile(tox):
tox = 'tox'
ret = subprocess.call(tox, shell=True)
self.assertEqual(ret, 0)
ret = subprocess.call('bin/gulp test', shell=True)
self.assertEqual(ret, 0)
ret = subprocess.call('flake8', shell=True)
self.assertEqual(ret, 0)