Skip to content

Commit

Permalink
Fix aws ssm accessing tests by setting default region when in testing…
Browse files Browse the repository at this point in the history
… mode
  • Loading branch information
anthonyhashemi committed Oct 27, 2023
1 parent 22bd5a5 commit a7b5cd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ def create_app(config_class=Config):
"script-src": ["'self'"],
}

# Disable https if app is run in testing mode
force_https = True if app.config["TESTING"] else False
force_https = True
if app.config["TESTING"]:
force_https = False
testing_region = "eu-west-2"
boto3.setup_default_session(region_name=testing_region)

# Initialise app extensions
assets.init_app(app)
Expand Down
4 changes: 2 additions & 2 deletions app/tests/test_aws_open_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@mock_ssm
def test_get_open_search_index_from_aws_params():
ssm_client = boto3.client("ssm", region_name="eu-west-2")
ssm_client = boto3.client("ssm")
ssm_client.put_parameter(
Name="ENVIRONMENT_NAME",
Value="test_env",
Expand All @@ -30,7 +30,7 @@ def test_get_open_search_index_from_aws_params():
@mock_ssm
@patch("app.main.aws.open_search.OpenSearch")
def test_generate_open_search_client_from_aws_params(mock_open_search):
ssm_client = boto3.client("ssm", region_name="eu-west-2")
ssm_client = boto3.client("ssm")
ssm_client.put_parameter(
Name="ENVIRONMENT_NAME",
Value="test_env",
Expand Down

0 comments on commit a7b5cd0

Please sign in to comment.