Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lambda_uploader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def raw(self):

return self._config

def set_publish(self):
self._config['publish'] = True

def _set_defaults(self):
for param, val in DEFAULT_PARAMS.iteritems():
if self._config.get(param) is None:
Expand Down
8 changes: 8 additions & 0 deletions lambda_uploader/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def _execute(args):
pth = path.abspath(args.function_dir)

cfg = config.Config(pth)
# Set publish if flagged to do so
if args.publish:
cfg.set_publish()

_print('Building Package')
pkg = package.build_package(pth, cfg.requirements)

Expand Down Expand Up @@ -78,6 +82,10 @@ def main(arv=None):
action='store_const',
help='dont cleanup the temporary workspace',
const=True)
parser.add_argument('--publish', '-p', dest='publish',
action='store_const',
help='publish an upload to an immutable version',
const=True)
parser.add_argument('function_dir', default=getcwd(), nargs='?',
help='lambda function directory')

Expand Down
26 changes: 26 additions & 0 deletions test/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from os import path
from lambda_uploader import config

EX_CONFIG = path.normpath(path.join(path.dirname(__file__),
'../example'))


def test_load_config():
cfg = config.Config(EX_CONFIG)

# Do a quick test of some attributes
attrs = {'name': 'myFunc',
'description': 'myfunc',
'region': 'us-east-1'}

for key, val in attrs.iteritems():
assert cfg.raw[key] == val


def test_set_publish():
cfg = config.Config(EX_CONFIG)
# Check that we default to false
assert cfg.publish is False

cfg.set_publish()
assert cfg.publish