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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
- import os
- import pytest
- from subprocess import check_output
- from conftest import system_check
- def no_curlies(filepath):
- """ Utility to make sure no curly braces appear in a file.
- That is, was jinja able to render everthing?
- """
- with open(filepath, 'r') as f:
- data = f.read()
- template_strings = [
- '{{',
- '}}',
- '{%',
- '%}'
- ]
- template_strings_in_file = [s in data for s in template_strings]
- return not any(template_strings_in_file)
- @pytest.mark.usefixtures("default_baked_project")
- class TestCookieSetup(object):
- def test_project_name(self):
- project = self.path
- if pytest.param.get('project_name'):
- name = system_check('DrivenData')
- assert project.name == name
- else:
- assert project.name == 'project_name'
- def test_author(self):
- setup_ = self.path / 'setup.py'
- args = ['python', setup_, '--author']
- p = check_output(args).decode('ascii').strip()
- if pytest.param.get('author_name'):
- assert p == 'DrivenData'
- else:
- assert p == 'Your name (or your organization/company/team)'
- def test_readme(self):
- readme_path = self.path / 'README.md'
- assert readme_path.exists()
- assert no_curlies(readme_path)
- if pytest.param.get('project_name'):
- with open(readme_path) as fin:
- assert 'DrivenData' == next(fin).strip()
- def test_setup(self):
- setup_ = self.path / 'setup.py'
- args = ['python', setup_, '--version']
- p = check_output(args).decode('ascii').strip()
- assert p == '0.1.0'
- def test_license(self):
- license_path = self.path / 'LICENSE'
- assert license_path.exists()
- assert no_curlies(license_path)
- def test_license_type(self):
- setup_ = self.path / 'setup.py'
- args = ['python', setup_, '--license']
- p = check_output(args).decode('ascii').strip()
- if pytest.param.get('open_source_license'):
- assert p == 'BSD-3'
- else:
- assert p == 'MIT'
- def test_requirements(self):
- reqs_path = self.path / 'requirements.txt'
- assert reqs_path.exists()
- assert no_curlies(reqs_path)
- if pytest.param.get('python_interpreter'):
- with open(reqs_path) as fin:
- lines = list(map(lambda x: x.strip(), fin.readlines()))
- assert 'pathlib2' in lines
- def test_makefile(self):
- makefile_path = self.path / 'Makefile'
- assert makefile_path.exists()
- assert no_curlies(makefile_path)
- def test_folders(self):
- expected_dirs = [
- 'data',
- 'data/external',
- 'data/interim',
- 'data/processed',
- 'data/raw',
- 'docs',
- 'models',
- 'notebooks',
- 'references',
- 'reports',
- 'reports/figures',
- 'src',
- 'src/data',
- 'src/features',
- 'src/models',
- 'src/visualization',
- ]
- ignored_dirs = [
- str(self.path)
- ]
- abs_expected_dirs = [str(self.path / d) for d in expected_dirs]
- abs_dirs, _, _ = list(zip(*os.walk(self.path)))
- assert len(set(abs_expected_dirs + ignored_dirs) - set(abs_dirs)) == 0
|