Skip to content

Commit 279f49e

Browse files
committed
add more flags and args, and stub unit tests
1 parent 158bb26 commit 279f49e

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

plugins/module_utils/faas.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818
'quiet': '--quiet',
1919
'shrinkwrap': '--shrinkwrap',
2020
},
21-
'deploy': {},
22-
'invoke': {},
23-
'list': {},
21+
'deploy': {
22+
'replace': '--replace',
23+
'update': '--update',
24+
},
25+
'list': {'verbose': '-v'},
2426
'login': {},
25-
'logs': {},
27+
'logs': {
28+
'instance': '--instance',
29+
'name': '--name',
30+
},
2631
'push': {},
2732
'remove': {},
2833
}
@@ -32,12 +37,17 @@
3237
ARGS_MAP: Final[dict[str, dict[str, str]]] = dict(
3338
{
3439
'build': {},
35-
'deploy': {},
36-
'invoke': {},
37-
'list': {},
38-
'login': {},
40+
'deploy': {
41+
'annotation': '',
42+
'label': '',
43+
},
44+
'list': {'sort': '--sort'},
45+
'login': {
46+
'username': '-u',
47+
'password': '-p',
48+
},
3949
'logs': {},
40-
'push': {},
50+
'push': {'parellel': '--parallel'},
4151
'remove': {},
4252
}
4353
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""unit test for faas module util"""
2+
3+
import pytest
4+
from mschuchard.general.plugins.module_utils import faas
5+
6+
7+
def test_faas_cmd_errors():
8+
"""test various cmd errors"""
9+
# test fails on unsupported action
10+
with pytest.raises(RuntimeError, match='Unsupported FaaS action attempted: foo'):
11+
faas.cmd(action='foo')
12+
13+
# test fails on nonexistent function file
14+
with pytest.raises(FileNotFoundError, match='Function config file does not exist or is invalid: /faas.yaml'):
15+
faas.cmd(action='build', args={'config_file': '/faas.yaml'})
16+
17+
# test fails on function file with invalid yaml content
18+
with pytest.warns(SyntaxWarning, match='Specified YAML or JSON file does not contain valid YAML or JSON: .gitignore'), pytest.raises(ValueError):
19+
faas.cmd(action='invoke', args={'config_file': '.gitignore'})
20+
21+
22+
def test_faas_cmd():
23+
"""test various cmd returns"""

0 commit comments

Comments
 (0)