-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/increase code coverage (#39)
* Changed step function names to be suitable for testing * Added tests for custom type steps. * Removed unnecessary imports * Removed unnecessary imports * Modified some steps a bit to be more flexible for testing without using patch * Added MockedStep and MockedWorld classes * Added new unit tests about @given steps * Added __init__.py into the tests/steps directory * Fixed string formatting on one of the tests * Fixed some of the class initiation parts on mocks. Also added self.stash on class init * Removed unnecessary imports * Added few more unit tests for steps * Added one more step test case. * Enabled coverage badge on README.md * Added few more tests * Bumped patch version by 1 * Removed unnecessary imports * Added few more unit tests * Fixed one of the steps where it was not failing on must cases * Fixed 2 unit tests and add another one. * Fixed a step where must and must not is not processed properly * Added 4 more unit tests and fixed 1 unit test
- Loading branch information
Showing
10 changed files
with
367 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ dist | |
example/tf_files/* | ||
terraform_compliance.egg-info | ||
|
||
.DS_Store | ||
.DS_Store | ||
terraform-compliance.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from unittest import TestCase | ||
from terraform_compliance.steps.steps import i_have_name_section_configured, i_have_resource_defined | ||
from tests.mocks import MockedStep, MockedWorld, MockedWorldConfigTerraform | ||
|
||
|
||
class Test_Given_Step_Cases(TestCase): | ||
|
||
def setUp(self): | ||
self.step = MockedStep() | ||
self.radish_world = MockedWorld() | ||
|
||
def test_i_have_name_section_configured(self): | ||
i_have_name_section_configured(self.step, 'resource_type', 'resource', self.radish_world) | ||
self.assertEqual(self.step.context.stash, MockedWorldConfigTerraform().terraform_config['resource']['resource_type']) | ||
|
||
i_have_name_section_configured(self.step, 'aws', 'provider', self.radish_world) | ||
self.assertEqual(self.step.context.stash, MockedWorldConfigTerraform().terraform_config['provider']['aws']) | ||
|
||
i_have_name_section_configured(self.step, 'non_existent', 'something_else', self.radish_world) | ||
self.assertEqual(self.step.context.stash, MockedWorldConfigTerraform().terraform_config['something_else']) | ||
|
||
i_have_name_section_configured(self.step, 'AWS S3 Bucket', 'resource', self.radish_world) | ||
self.assertEqual(self.step.context.stash, MockedWorldConfigTerraform().terraform_config['resource']['aws_s3_bucket']) | ||
|
||
def test_i_have_resource_defined(self): | ||
i_have_resource_defined(self.step, 'resource_type', self.radish_world) | ||
self.assertEqual(self.step.context.stash, MockedWorldConfigTerraform().terraform_config['resource']['resource_type']) | ||
|
||
i_have_resource_defined(self.step, 'AWS S3 Bucket', self.radish_world) | ||
self.assertEqual(self.step.context.stash, MockedWorldConfigTerraform().terraform_config['resource']['aws_s3_bucket']) | ||
|
Oops, something went wrong.