Skip to content

Commit b980bfe

Browse files
author
Matt Bernier
authored
Merge pull request #42 from bertuss/issue#40-unittest-to-check-for-specific-repo-files
Issue#40 unittest to check for specific repo files
2 parents 4033658 + d1d2168 commit b980bfe

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

test/__init__.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import unittest, json, decimal
1+
import unittest, json, decimal, os
22
from smtpapi import SMTPAPIHeader
33

4+
45
class TestSMTPAPI(unittest.TestCase):
56

67
def setUp(self):
@@ -72,5 +73,41 @@ def test_drop_empty(self):
7273
self.assertEqual(self.dropsHeader, json.loads(header.json_string()))
7374

7475

76+
class TestRepository(unittest.TestCase):
77+
78+
def setUp(self):
79+
80+
self.required_files = [
81+
['./Dockerfile', './docker/Dockerfile'],
82+
['./docker-compose.yml', './docker/docker-compose.yml'],
83+
'./.codeclimate.yml',
84+
'./.env_sample',
85+
'./.github/ISSUE_TEMPLATE',
86+
'./.github/PULL_REQUEST_TEMPLATE',
87+
'./.gitignore',
88+
'./.travis.yml',
89+
'./CHANGELOG.md',
90+
'./CODE_OF_CONDUCT.md',
91+
'./CONTRIBUTING.md',
92+
['./LICENSE.md', './License.txt'],
93+
'./README.md',
94+
'./TROUBLESHOOTING.md',
95+
'./USAGE.md',
96+
'./USE_CASES.md',
97+
]
98+
99+
self.file_not_found_message = 'File "{0}" does not exist in repo!'
100+
101+
def test_repository_files_exists(self):
102+
103+
for file_path in self.required_files:
104+
if isinstance(file_path, list):
105+
# multiple file paths: assert that any one of the files exists
106+
self.assertTrue(any(os.path.exists(f) for f in file_path),
107+
msg=self.file_not_found_message.format('" or "'.join(file_path)))
108+
else:
109+
self.assertTrue(os.path.exists(file_path), msg=self.file_not_found_message.format(file_path))
110+
111+
75112
if __name__ == '__main__':
76113
unittest.main()

0 commit comments

Comments
 (0)