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

Fix/exclude add when initial zappa setting #1242

Merged
merged 11 commits into from
Nov 10, 2023
22 changes: 22 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import shutil
import string
import subprocess
import sys
import tempfile
import unittest
Expand Down Expand Up @@ -1122,6 +1123,27 @@ def test_wsgi_from_apigateway_testbutton(self):
# CLI
##

def test_zappa_init(self):
# delete if file exists
if os.path.exists("zappa_settings.json"):
os.remove("zappa_settings.json")

process = subprocess.Popen(
["zappa", "init"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True
)
process.communicate("dev\nmy-zappa-bucket\ntest_settings\ndefault\nn\ny\n")
self.assertTrue(os.path.exists("zappa_settings.json"))

with open("zappa_settings.json", "r") as f:
zappa_settings = json.load(f)
self.assertEqual(zappa_settings["dev"]["s3_bucket"], "my-zappa-bucket")
self.assertEqual(zappa_settings["dev"]["django_settings"], "test_settings")
self.assertEqual(zappa_settings["dev"]["exclude"], ["boto3", "dateutil", "botocore", "s3transfer", "concurrent"])

# delete the file
if os.path.exists("zappa_settings.json"):
os.remove("zappa_settings.json")

def test_cli_sanity(self):
zappa_cli = ZappaCLI()
return
Expand Down
3 changes: 2 additions & 1 deletion zappa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,7 @@ def init(self, settings_file="zappa_settings.json"):
"s3_bucket": bucket,
"runtime": get_venv_from_python_version(),
"project_name": self.get_project_name(),
"exclude": ["boto3", "dateutil", "botocore", "s3transfer", "concurrent"],
monkut marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -2434,7 +2435,7 @@ def create_package(self, output=None, use_zappa_release: Optional[str] = None):
disable_progress=self.disable_progress,
)
else:
exclude = self.stage_config.get("exclude", ["boto3", "dateutil", "botocore", "s3transfer", "concurrent"])
exclude = self.stage_config.get("exclude", [])

# Create a single zip that has the handler and application
self.zip_path = self.zappa.create_lambda_zip(
Expand Down