1140
1141
self.assertIsInstance(command, command_cls)
1141
1142
for key, value in cmd_attrs.items():
1142
1143
self.assertEqual(getattr(command, key), value)
1143
def test_default_is_show_table(self):
1144
def test_print_table(self):
1144
1145
self.assert_command_from_args([], PrintTableCmd,
1146
def test_show_table_verbose(self):
1148
def test_print_table_verbose(self):
1147
1149
self.assert_command_from_args(["--verbose"], PrintTableCmd,
1149
1152
def test_enable(self):
1150
1153
self.assert_command_from_args(["--enable", "foo"], EnableCmd)
1151
1155
def test_disable(self):
1152
1156
self.assert_command_from_args(["--disable", "foo"],
1159
def test_bump_timeout(self):
1160
self.assert_command_from_args(["--bump-timeout", "foo"],
1163
def test_start_checker(self):
1164
self.assert_command_from_args(["--start-checker", "foo"],
1167
def test_stop_checker(self):
1168
self.assert_command_from_args(["--stop-checker", "foo"],
1171
def test_remove(self):
1172
self.assert_command_from_args(["--remove", "foo"],
1175
def test_checker(self):
1176
self.assert_command_from_args(["--checker", ":", "foo"],
1177
SetCheckerCmd, value_to_set=":")
1179
def test_timeout(self):
1180
self.assert_command_from_args(["--timeout", "PT5M", "foo"],
1182
value_to_set=300000)
1184
def test_extended_timeout(self):
1185
self.assert_command_from_args(["--extended-timeout", "PT15M",
1187
SetExtendedTimeoutCmd,
1188
value_to_set=900000)
1190
def test_interval(self):
1191
self.assert_command_from_args(["--interval", "PT2M", "foo"],
1193
value_to_set=120000)
1195
def test_approve_by_default(self):
1196
self.assert_command_from_args(["--approve-by-default", "foo"],
1197
ApproveByDefaultCmd)
1199
def test_deny_by_default(self):
1200
self.assert_command_from_args(["--deny-by-default", "foo"],
1203
def test_approval_delay(self):
1204
self.assert_command_from_args(["--approval-delay", "PT30S",
1205
"foo"], SetApprovalDelayCmd,
1208
def test_approval_duration(self):
1209
self.assert_command_from_args(["--approval-duration", "PT1S",
1210
"foo"], SetApprovalDurationCmd,
1213
def test_host(self):
1214
self.assert_command_from_args(["--host", "foo.example.org",
1216
value_to_set="foo.example.org")
1218
def test_secret_devnull(self):
1219
self.assert_command_from_args(["--secret", os.path.devnull,
1220
"foo"], SetSecretCmd,
1223
def test_secret_tempfile(self):
1224
with tempfile.NamedTemporaryFile(mode="r+b") as f:
1225
value = b"secret\0xyzzy\nbar"
1228
self.assert_command_from_args(["--secret", f.name,
1229
"foo"], SetSecretCmd,
1232
def test_approve(self):
1233
self.assert_command_from_args(["--approve", "foo"],
1236
def test_deny(self):
1237
self.assert_command_from_args(["--deny", "foo"], DenyCmd)
1239
def test_dump_json(self):
1240
self.assert_command_from_args(["--dump-json"], DumpJSONCmd)
1242
def test_is_enabled(self):
1243
self.assert_command_from_args(["--is-enabled", "foo"],
1157
1248
def should_only_run_tests():