|
1 | 1 | from os import path |
2 | 2 | from lambda_uploader import config |
| 3 | +import pytest |
3 | 4 |
|
4 | 5 | EX_CONFIG = path.normpath(path.join(path.dirname(__file__), |
5 | 6 | '../test/configs')) |
@@ -57,6 +58,35 @@ def test_set_publish(): |
57 | 58 |
|
58 | 59 |
|
59 | 60 | def test___getattr__(): |
60 | | - cfg = config.Config(EX_CONFIG, EX_CONFIG + '/lambda.json') |
| 61 | + cfg = config.Config(EX_CONFIG, path.join(EX_CONFIG, 'lambda.json')) |
61 | 62 | assert cfg.s3_bucket is None |
62 | 63 | assert cfg.name == 'myFunc' |
| 64 | + |
| 65 | + |
| 66 | +def test_invalid_config_as_dir(): |
| 67 | + # pass the function directory as the lambda configuration -- |
| 68 | + # this should not work! |
| 69 | + with pytest.raises(Exception): |
| 70 | + config.Config(EX_CONFIG, EX_CONFIG) |
| 71 | + |
| 72 | + |
| 73 | +def test_invalid_config_missing_file(): |
| 74 | + # try invalid file |
| 75 | + with pytest.raises(Exception): |
| 76 | + config.Config(EX_CONFIG, path.join(EX_CONFIG, 'pleasedontexist.json')) |
| 77 | + |
| 78 | + |
| 79 | +def test_invalid_config_missing_function_dir(): |
| 80 | + # try invalid file |
| 81 | + with pytest.raises(Exception): |
| 82 | + config.Config(path.join(EX_CONFIG, 'pleasedontexist_dir')) |
| 83 | + |
| 84 | + |
| 85 | +def test_invalid_config_missing_function_dir2(): |
| 86 | + with pytest.raises(Exception): |
| 87 | + config.Config( |
| 88 | + # invalid function dir |
| 89 | + path.join(EX_CONFIG, 'pleasedontexist_dir'), |
| 90 | + # valid config file |
| 91 | + path.join(EX_CONFIG, 'lambda.json') |
| 92 | + ) |
0 commit comments