Repository: awslabs/seed-farmer (language: python)

Issue:
Made changed to testing to reflect cli changes; simplified the test d…
Fixed some testing issues


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2048f84..1c9555f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,13 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
 ### New
 ### Changes
 
+### Fixes
+
+## v2.2.1 (2022-10-25)
+
+### New
+### Changes
+
 ### Fixes
 - seedfarmer apply was not picking up .env at same level as `seedfarmer.yaml`
 - all `list` functions did not respect the .env path relative to `seedfarmer.yaml`
diff --git a/VERSION b/VERSION
index df2a6cb1..c043eea7 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-2.3.0.dev0
+2.2.1


Test patch:
diff --git a/test/unit-test/mock_data/manifests/module-test/deployment.yaml b/test/unit-test/mock_data/manifests/module-test/deployment.yaml
index 3f1075ed..666e8a70 100644
--- a/test/unit-test/mock_data/manifests/module-test/deployment.yaml
+++ b/test/unit-test/mock_data/manifests/module-test/deployment.yaml
@@ -2,7 +2,7 @@ name: example-test-dev
 toolchainRegion: us-west-2
 groups:
   - name: test
-    path: manifests/module-test/test-modules.yaml
+    path: test/unit-test/mock_data/manifests/module-test/test-modules.yaml
 targetAccountMappings:
   - alias: primary
     accountId:
diff --git a/test/unit-test/mock_data/manifests/module-test/test-modules.yaml b/test/unit-test/mock_data/manifests/module-test/test-modules.yaml
index 901be277..fe877d8b 100644
--- a/test/unit-test/mock_data/manifests/module-test/test-modules.yaml
+++ b/test/unit-test/mock_data/manifests/module-test/test-modules.yaml
@@ -1,5 +1,5 @@
 name: test-module
-path: modules/module-test/
+path: test/unit-test/mock_data/modules/module-test/
 parameters:
-  - name: domain_name_prefix
-    value: testdomaindomaintester-a
+  - name: event_bridge_enabled
+    value: "False"
diff --git a/test/unit-test/mock_data/manifests/test-broken-deployspec-deploy/deployment.yaml b/test/unit-test/mock_data/manifests/test-broken-deployspec-deploy/deployment.yaml
index 7315218f..639e2776 100644
--- a/test/unit-test/mock_data/manifests/test-broken-deployspec-deploy/deployment.yaml
+++ b/test/unit-test/mock_data/manifests/test-broken-deployspec-deploy/deployment.yaml
@@ -2,7 +2,7 @@ name: test-broken-deployspec-deploy
 toolchainRegion: us-west-2
 groups:
   - name: test
-    path: manifests/test-broken-deployspec-deploy/test-module.yamlxddd
+    path: test/unit-test/mock_data/manifests/test-broken-deployspec-deploy/test-module.yamlxddd
 targetAccountMappings:
   - alias: primary
     accountId:
diff --git a/test/unit-test/mock_data/manifests/test-broken-deployspec-destroy/deployment.yaml b/test/unit-test/mock_data/manifests/test-broken-deployspec-destroy/deployment.yaml
index 1595bea5..be64332c 100644
--- a/test/unit-test/mock_data/manifests/test-broken-deployspec-destroy/deployment.yaml
+++ b/test/unit-test/mock_data/manifests/test-broken-deployspec-destroy/deployment.yaml
@@ -2,7 +2,7 @@ name: test-broken-deployspec-destroy
 toolchainRegion: us-west-2
 groups:
   - name: test
-    path: manifests/test-broken-deployspec-destroy/test-module.yaml
+    path: test/unit-test/mock_data/manifests/test-broken-deployspec-destroy/test-module.yaml
 targetAccountMappings:
   - alias: primary
     accountId:
diff --git a/test/unit-test/mock_data/manifests/test-missing-deployment-group-name/deployment.yaml b/test/unit-test/mock_data/manifests/test-missing-deployment-group-name/deployment.yaml
index c8f28fe4..947c33ed 100644
--- a/test/unit-test/mock_data/manifests/test-missing-deployment-group-name/deployment.yaml
+++ b/test/unit-test/mock_data/manifests/test-missing-deployment-group-name/deployment.yaml
@@ -2,7 +2,7 @@ name: test-missing-deployment-group-name
 toolchainRegion: us-west-2
 groups:
   - name:
-    path: manifests/test-missing-deployment-group-name/test-module.yaml
+    path: test/unit-test/mock_data/manifests/test-missing-deployment-group-name/test-module.yaml
 targetAccountMappings:
   - alias: primary
     accountId:
diff --git a/test/unit-test/mock_data/modules/module-test/app.py b/test/unit-test/mock_data/modules/module-test/app.py
index d157acbb..97164846 100644
--- a/test/unit-test/mock_data/modules/module-test/app.py
+++ b/test/unit-test/mock_data/modules/module-test/app.py
@@ -1,18 +1,17 @@
 import os
 
 from aws_cdk import App, CfnOutput
-from stack import Cognito
+from stack import S3
 
 deployment_name = os.getenv("MYAPP_DEPLOYMENT_NAME")
 module_name = os.getenv("MYAPP_MODULE_NAME")
-domain_name_prefix = os.getenv("MYAPP_PARAMETER_DOMAIN_NAME_PREFIX", "")
+event_bridge_enabled = os.getenv("MYAPP_PARAMETER_EVENT_BRIDGE_ENABLED", False)
 
 app = App()
 
-stack = Cognito(
+stack = S3(
     scope=app,
     id=f"myapp-{deployment_name}-{module_name}",
-    domain_name_prefix=domain_name_prefix,
 )
 
 CfnOutput(
@@ -20,9 +19,7 @@
     id="metadata",
     value=stack.to_json_string(
         {
-            "CognitoDomainName": stack.cognito_domain.domain_name,
-            "CognitoUserPoolArn": stack.cognito_user_pool.user_pool_arn,
-            "CognitoPoolClientId": stack.cognito_user_pool_client.user_pool_client_id,
+            "BucketName": stack.bucket.bucket_name,
         }
     ),
 )
diff --git a/test/unit-test/mock_data/modules/module-test/stack.py b/test/unit-test/mock_data/modules/module-test/stack.py
index 39113de7..f301c48d 100644
--- a/test/unit-test/mock_data/modules/module-test/stack.py
+++ b/test/unit-test/mock_data/modules/module-test/stack.py
@@ -16,8 +16,8 @@
 import os
 from typing import Any
 
-from aws_cdk import Duration, Stack
-from aws_cdk import aws_cognito as cognito
+from aws_cdk import Stack
+from aws_cdk import aws_s3 as s3
 from constructs import Construct
 
 _logger: logging.Logger = logging.getLogger(__name__)
@@ -25,53 +25,16 @@
 project_dir = os.path.dirname(os.path.abspath(__file__))
 
 
-class Cognito(Stack):
+class S3(Stack):
     def __init__(
         self,
         scope: Construct,
         id: str,
-        domain_name_prefix: str,
         **kwargs: Any,
     ) -> None:
         super().__init__(scope, id, **kwargs)
 
-        self.cognito_user_pool = cognito.UserPool(
+        self.bucket = s3.Bucket(
             self,
-            id="CognitoUserPool",
-            account_recovery=cognito.AccountRecovery.EMAIL_ONLY,
-            auto_verify=cognito.AutoVerifiedAttrs(email=True, phone=False),
-            password_policy=cognito.PasswordPolicy(
-                min_length=8,
-                require_digits=True,
-                require_lowercase=True,
-                require_symbols=True,
-                require_uppercase=True,
-                temp_password_validity=Duration.days(5),
-            ),
-            self_sign_up_enabled=False,
-            user_invitation=cognito.UserInvitationConfig(
-                email_subject="Invite to join!",
-                email_body="Hello, you have been invited!<br/><br/>"
-                "Username: {username}<br/>"
-                "Temporary password: {####}<br/><br/>"
-                "Regards",
-            ),
-            user_verification=cognito.UserVerificationConfig(
-                email_subject="Verify your email",
-                email_body="Thanks for signing up! Your verification code is {####}",
-                email_style=cognito.VerificationEmailStyle.CODE,
-            ),
-        )
-
-        self.cognito_user_pool_client = cognito.UserPoolClient(
-            self,
-            id="UserPoolClient",
-            user_pool=self.cognito_user_pool,
-        )
-
-        self.cognito_domain = cognito.UserPoolDomain(
-            self,
-            "CognitoDomain",
-            user_pool=self.cognito_user_pool,
-            cognito_domain=cognito.CognitoDomainOptions(domain_prefix=domain_name_prefix),
+            id="BucketTesting",
         )
diff --git a/test/unit-test/test_cli_arg.py b/test/unit-test/test_cli_arg.py
index d7311009..895fc6d6 100644
--- a/test/unit-test/test_cli_arg.py
+++ b/test/unit-test/test_cli_arg.py
@@ -24,7 +24,9 @@
 from seedfarmer.__main__ import remove, store
 
 # Override OPS_ROOT to reflect path of resource policy needed for some testing #
-config.OPS_ROOT = os.path.join(config.OPS_ROOT, "test/unit-test/mock_data")
+_OPS_ROOT = config.OPS_ROOT
+_TEST_ROOT = os.path.join(config.OPS_ROOT, "test/unit-test/mock_data")
+_PROJECT = config.PROJECT
 
 _logger: logging.Logger = logging.getLogger(__name__)
 
@@ -36,7 +38,7 @@
 @pytest.mark.init
 def test_init_create_module():
     module_name = "test-module"
-    expected_module_path = os.path.join(config.OPS_ROOT, "modules")
+    expected_module_path = os.path.join(_OPS_ROOT, "modules")
 
     # Creates a new module
     _test_command(sub_command=init, options=["module", "-m", module_name], exit_code=0, return_result=False)
@@ -54,7 +56,7 @@ def test_init_create_module():
 def test_init_create_group_module():
     module_name = "test-module"
     group_name = "group"
-    expected_module_path = os.path.join(config.OPS_ROOT, "modules", group_name, module_name)
+    expected_module_path = os.path.join(_OPS_ROOT, "modules", group_name, module_name)
 
     # Creates a group and a module within the group
     _test_command(sub_command=init, options=["module", "-g", group_name, "-m", module_name], exit_code=0)
@@ -66,7 +68,7 @@ def test_init_create_group_module():
     )
     assert (
         result.exception.args[0]
-        == f"The module {module_name} already exists under {config.OPS_ROOT}/modules/{group_name}."
+        == f"The module {module_name} already exists under {_OPS_ROOT}/modules/{group_name}."
     )
 
     # Checks if a file from the project template was created within the new module
@@ -75,7 +77,7 @@ def test_init_create_group_module():
 
 @pytest.mark.init
 def test_init_create_project():
-    expected_project_path = os.path.join(config.OPS_ROOT, config.PROJECT)
+    expected_project_path = os.path.join(_OPS_ROOT, _PROJECT)
 
     # Creates a new project
     _test_command(sub_command=init, options=["project"], exit_code=0, return_result=False)
@@ -83,7 +85,7 @@ def test_init_create_project():
     # Creates a project that already exist
     result = _test_command(sub_command=init, options=["project"], exit_code=1, return_result=True)
     assert (
-        result.exception.args[0] == f'Error: "{os.path.join(config.OPS_ROOT, config.PROJECT)}" directory already exists'
+        result.exception.args[0] == f'Error: "{os.path.join(_OPS_ROOT, _PROJECT)}" directory already exists'
     )
 
     # Checks if file exists from the project template
@@ -109,14 +111,14 @@ def test_apply_help():
 @pytest.mark.apply_working_module
 def test_apply_deployment():
     # Deploys a functioning module
-    deployment_manifest = "manifests/module-test/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/module-test/deployment.yaml"
 
     _test_command(sub_command=apply, options=deployment_manifest, exit_code=0)
 
 
 @pytest.mark.apply
 def test_apply_missing_deployment():
-    deployment_manifest = "manifests/test-missing-deployment-manifest/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/test-missing-deployment-manifest/deployment.yaml"
 
     result = _test_command(sub_command=apply, options=deployment_manifest, exit_code=1, return_result=True)
     assert result.exception.args[1] == "No such file or directory"
@@ -124,7 +126,7 @@ def test_apply_missing_deployment():
 
 @pytest.mark.apply
 def test_apply_missing_group_manifest():
-    deployment_manifest = "manifests/test-missing-group-manifest/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/test-missing-group-manifest/deployment.yaml"
 
     result = _test_command(sub_command=apply, options=deployment_manifest, exit_code=1, return_result=True)
     assert result.exception.args[1] == "No such file or directory"
@@ -132,15 +134,16 @@ def test_apply_missing_group_manifest():
 
 @pytest.mark.apply
 def test_apply_missing_deployment_group_name():
-    deployment_manifest = "manifests/test-missing-deployment-group-name/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/test-missing-deployment-group-name/deployment.yaml"
 
     result = _test_command(sub_command=apply, options=deployment_manifest, exit_code=1, return_result=True)
     assert result.exception.args[0][0][0].exc.errors()[0]["msg"] == "none is not an allowed value"
 
 
+@pytest.mark.apply2
 @pytest.mark.apply
 def test_apply_missing_deployment_group_path():
-    deployment_manifest = "manifests/test-missing-deployment-group-path/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/test-missing-deployment-group-path/deployment.yaml"
 
     result = _test_command(sub_command=apply, options=deployment_manifest, exit_code=1, return_result=True)
     assert result.exception.args[0] == "One of the `path` or `modules` attributes must be defined on a Group"
@@ -148,7 +151,7 @@ def test_apply_missing_deployment_group_path():
 
 @pytest.mark.apply
 def test_apply_missing_deployment_name():
-    deployment_manifest = "manifests/test-missing-deployment-name/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/test-missing-deployment-name/deployment.yaml"
 
     result = _test_command(sub_command=apply, options=deployment_manifest, exit_code=1, return_result=True)
     assert result.exception.args[0][0].exc.msg_template == "none is not an allowed value"
@@ -156,7 +159,7 @@ def test_apply_missing_deployment_name():
 
 @pytest.mark.apply
 def test_apply_broken_deploy_phase():
-    deployment_manifest = "manifests/test-broken-deployspec-deploy/deployment.yaml"
+    deployment_manifest = f"{_TEST_ROOT}/manifests/test-broken-deployspec-deploy/deployment.yaml"
 
     _test_command(sub_command=apply, options=deployment_manifest, exit_code=1, return_result=True)
     # assert result.exception.args[0][0].exc.errors()[0]["msg"] == "none is not an allowed value"
@@ -165,7 +168,7 @@ def test_apply_broken_deploy_phase():
 # # TODO add test for broken destroy phase
 # @pytest.mark.destroy
 # def test_destroy_broken_deploy_phase():
-#     deployment_manifest = "manifests/test-broken-deployspec-destroy/deployment.yaml"
+#     deployment_manifest = f"{_TEST_ROOT}/manifests/test-broken-deployspec-destroy/deployment.yaml"
 
 #     result = _test_command(sub_command=destroy, options=deployment_manifest, exit_code=1, return_result=True)
 #     assert result.exception.args[0][0].exc.errors()[0]['msg'] == "none is not an allowed value"