Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Issue#40 unittest to check for specific repo files #42

Merged
merged 5 commits into from
Nov 1, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest, json, decimal
import unittest, json, decimal, os
from smtpapi import SMTPAPIHeader


class TestSMTPAPI(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -72,5 +73,41 @@ def test_drop_empty(self):
self.assertEqual(self.dropsHeader, json.loads(header.json_string()))


class TestRepository(unittest.TestCase):

def setUp(self):

self.required_files = [
['./Docker', './docker/Docker'],
['./docker-compose.yml', './docker/docker-compose.yml'],
'./.codeclimate.yml',
'./.env_sample',
'./.github/ISSUE_TEMPLATE',
'./.github/PULL_REQUEST_TEMPLATE',
'./.gitignore',
'./.travis.yml',
'./CHANGELOG.md',
'./CODE_OF_CONDUCT.md',
'./CONTRIBUTING.md',
'./LICENSE.md',
'./README.md',
'./TROUBLESHOOTING.md',
'./USAGE.md',
'./USE_CASES.md',
]

self.file_not_found_message = 'File "{}" does not exist in repo!'

def test_repository_files_exists(self):

for file_path in self.required_files:
if isinstance(file_path, list):
# multiple file paths: assert that any one of the files exists
self.assertTrue(any(os.path.exists(f) for f in file_path),
msg=self.file_not_found_message.format('" or "'.join(file_path)))
else:
self.assertTrue(os.path.exists(file_path), msg=self.file_not_found_message.format(file_path))


if __name__ == '__main__':
unittest.main()