Skip to content

Commit ab6001f

Browse files
committed
chore(main): init subcommand args for GAM, GYB
1 parent 51c5ce7 commit ab6001f

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

compiler_admin/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ def _subcmd(name, help, add_username_arg=True) -> argparse.ArgumentParser:
3535

3636
_subcmd("info", help="Print configuration and debugging information.", add_username_arg=False)
3737

38-
_subcmd(
38+
init_parser = _subcmd(
3939
"init",
4040
help="Initialize a new admin project. This command should be run once before any others.",
4141
)
42+
init_parser.add_argument("--gam", action="store_true", help="If provided, initialize a new GAM project.")
43+
init_parser.add_argument("--gyb", action="store_true", help="If provided, initialize a new GYB project.")
4244

4345
_subcmd("create", help="Create a new user in the Compiler domain.")
4446

@@ -70,7 +72,7 @@ def _subcmd(name, help, add_username_arg=True) -> argparse.ArgumentParser:
7072
elif args.command == "delete":
7173
return delete(args.username)
7274
elif args.command == "init":
73-
return init(args.username)
75+
return init(args.username, gam=args.gam, gyb=args.gyb)
7476
elif args.command == "offboard":
7577
return offboard(args.username, args.alias)
7678
elif args.command == "restore":

tests/test_main.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,28 @@ def test_main_info_default(mock_commands_info):
108108
mock_commands_info.assert_called_once()
109109

110110

111-
def test_main_init(mock_commands_init):
111+
def test_main_init_default(mock_commands_init):
112112
main(argv=["init", "username"])
113113

114114
mock_commands_init.assert_called_once()
115-
call_args = mock_commands_init.call_args.args
116-
assert "username" in call_args
115+
assert mock_commands_init.call_args.args == ("username",)
116+
assert mock_commands_init.call_args.kwargs == {"gam": False, "gyb": False}
117+
118+
119+
def test_main_init_gam(mock_commands_init):
120+
main(argv=["init", "username", "--gam"])
121+
122+
mock_commands_init.assert_called_once()
123+
assert mock_commands_init.call_args.args == ("username",)
124+
assert mock_commands_init.call_args.kwargs == {"gam": True, "gyb": False}
125+
126+
127+
def test_main_init_gyb(mock_commands_init):
128+
main(argv=["init", "username", "--gyb"])
129+
130+
mock_commands_init.assert_called_once()
131+
assert mock_commands_init.call_args.args == ("username",)
132+
assert mock_commands_init.call_args.kwargs == {"gam": False, "gyb": True}
117133

118134

119135
def test_main_init_no_username(mock_commands_init):

0 commit comments

Comments
 (0)