Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_creation.py 3.3 KB

You have to be logged in to leave a comment. Sign In
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
  1. import os
  2. import pytest
  3. from subprocess import check_output
  4. from conftest import system_check
  5. def no_curlies(filepath):
  6. """ Utility to make sure no curly braces appear in a file.
  7. That is, was jinja able to render everthing?
  8. """
  9. with open(filepath, 'r') as f:
  10. data = f.read()
  11. template_strings = [
  12. '{{',
  13. '}}',
  14. '{%',
  15. '%}'
  16. ]
  17. template_strings_in_file = [s in data for s in template_strings]
  18. return not any(template_strings_in_file)
  19. @pytest.mark.usefixtures("default_baked_project")
  20. class TestCookieSetup(object):
  21. def test_project_name(self):
  22. project = self.path
  23. if pytest.param.get('project_name'):
  24. name = system_check('DrivenData')
  25. assert project.name == name
  26. else:
  27. assert project.name == 'project_name'
  28. def test_author(self):
  29. setup_ = self.path / 'setup.py'
  30. args = ['python', setup_, '--author']
  31. p = check_output(args).decode('ascii').strip()
  32. if pytest.param.get('author_name'):
  33. assert p == 'DrivenData'
  34. else:
  35. assert p == 'Your name (or your organization/company/team)'
  36. def test_readme(self):
  37. readme_path = self.path / 'README.md'
  38. assert readme_path.exists()
  39. assert no_curlies(readme_path)
  40. if pytest.param.get('project_name'):
  41. with open(readme_path) as fin:
  42. assert 'DrivenData' == next(fin).strip()
  43. def test_setup(self):
  44. setup_ = self.path / 'setup.py'
  45. args = ['python', setup_, '--version']
  46. p = check_output(args).decode('ascii').strip()
  47. assert p == '0.1.0'
  48. def test_license(self):
  49. license_path = self.path / 'LICENSE'
  50. assert license_path.exists()
  51. assert no_curlies(license_path)
  52. def test_license_type(self):
  53. setup_ = self.path / 'setup.py'
  54. args = ['python', setup_, '--license']
  55. p = check_output(args).decode('ascii').strip()
  56. if pytest.param.get('open_source_license'):
  57. assert p == 'BSD-3'
  58. else:
  59. assert p == 'MIT'
  60. def test_requirements(self):
  61. reqs_path = self.path / 'requirements.txt'
  62. assert reqs_path.exists()
  63. assert no_curlies(reqs_path)
  64. if pytest.param.get('python_interpreter'):
  65. with open(reqs_path) as fin:
  66. lines = list(map(lambda x: x.strip(), fin.readlines()))
  67. assert 'pathlib2' in lines
  68. def test_makefile(self):
  69. makefile_path = self.path / 'Makefile'
  70. assert makefile_path.exists()
  71. assert no_curlies(makefile_path)
  72. def test_folders(self):
  73. expected_dirs = [
  74. 'data',
  75. 'data/external',
  76. 'data/interim',
  77. 'data/processed',
  78. 'data/raw',
  79. 'docs',
  80. 'models',
  81. 'notebooks',
  82. 'references',
  83. 'reports',
  84. 'reports/figures',
  85. 'src',
  86. 'src/data',
  87. 'src/features',
  88. 'src/models',
  89. 'src/visualization',
  90. ]
  91. ignored_dirs = [
  92. str(self.path)
  93. ]
  94. abs_expected_dirs = [str(self.path / d) for d in expected_dirs]
  95. abs_dirs, _, _ = list(zip(*os.walk(self.path)))
  96. assert len(set(abs_expected_dirs + ignored_dirs) - set(abs_dirs)) == 0
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...