From 24f144cf0418545d98ed8a869e0fd5958262a7f9 Mon Sep 17 00:00:00 2001 From: Bertus Steenberg Date: Sat, 28 Oct 2017 21:10:32 +0200 Subject: [PATCH 1/5] Add unittest to check that specific files exists in repo Issue #40 --- test/__init__.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index 315fc88..af9cc6f 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1,6 +1,7 @@ -import unittest, json, decimal +import unittest, json, decimal, os from smtpapi import SMTPAPIHeader + class TestSMTPAPI(unittest.TestCase): def setUp(self): @@ -72,5 +73,40 @@ 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): + 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() From db3d61ece1c28b0a828f894f383a40b11e6568c1 Mon Sep 17 00:00:00 2001 From: Bertus Steenberg Date: Sat, 28 Oct 2017 21:24:32 +0200 Subject: [PATCH 2/5] comment --- test/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/__init__.py b/test/__init__.py index af9cc6f..b99acd1 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -102,6 +102,7 @@ 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: From b9312128184dfd901d362f606cbe4164e052ba99 Mon Sep 17 00:00:00 2001 From: Bertus Steenberg Date: Sun, 29 Oct 2017 10:04:24 +0200 Subject: [PATCH 3/5] python2.6 format index --- test/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index b99acd1..77b0ce2 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -96,7 +96,7 @@ def setUp(self): './USE_CASES.md', ] - self.file_not_found_message = 'File "{}" does not exist in repo!' + self.file_not_found_message = 'File "{0}" does not exist in repo!' def test_repository_files_exists(self): From d56d3f0759419e0cd0cbf739982135c1a2dd89e6 Mon Sep 17 00:00:00 2001 From: Matt Bernier Date: Mon, 30 Oct 2017 21:34:32 -0600 Subject: [PATCH 4/5] Docker->Dockerfile This was my fault - my apologies --- test/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index 77b0ce2..fd66b72 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -78,7 +78,7 @@ class TestRepository(unittest.TestCase): def setUp(self): self.required_files = [ - ['./Docker', './docker/Docker'], + ['./Dockerfile', './docker/Dockerfile'], ['./docker-compose.yml', './docker/docker-compose.yml'], './.codeclimate.yml', './.env_sample', From d1d2168065a403d0cd62dc24e9f3bb50ea50d76b Mon Sep 17 00:00:00 2001 From: Matt Bernier Date: Tue, 31 Oct 2017 22:12:35 -0600 Subject: [PATCH 5/5] Added License.txt --- test/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index fd66b72..53db34a 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -89,7 +89,7 @@ def setUp(self): './CHANGELOG.md', './CODE_OF_CONDUCT.md', './CONTRIBUTING.md', - './LICENSE.md', + ['./LICENSE.md', './License.txt'], './README.md', './TROUBLESHOOTING.md', './USAGE.md',