|
2 | 2 | distutils commands for riak-python-client |
3 | 3 | """ |
4 | 4 |
|
5 | | -__all__ = ['create_bucket_types', 'setup_security', 'preconfig_security'] |
| 5 | +__all__ = ['create_bucket_types', 'setup_security', 'preconfig_security', |
| 6 | + 'setup_tests'] |
6 | 7 |
|
7 | 8 | from distutils import log |
8 | 9 | from distutils.core import Command |
@@ -206,13 +207,16 @@ class setup_security(Command): |
206 | 207 |
|
207 | 208 | def initialize_options(self): |
208 | 209 | self.riak_admin = None |
209 | | - # Default values: |
210 | | - self.username = 'testuser' |
211 | | - self.password = 'testpassword' |
| 210 | + self.username = None |
| 211 | + self.password = None |
212 | 212 |
|
213 | 213 | def finalize_options(self): |
214 | 214 | if self.riak_admin is None: |
215 | 215 | raise DistutilsOptionError("riak-admin option not set") |
| 216 | + if self.username is None: |
| 217 | + self.username = 'testuser' |
| 218 | + if self.password is None: |
| 219 | + self.password = 'testpassword' |
216 | 220 |
|
217 | 221 | def run(self): |
218 | 222 | if self._check_available(): |
@@ -386,3 +390,39 @@ def _backup_file(self, name): |
386 | 390 | shutil.copyfile(name, backup) |
387 | 391 | else: |
388 | 392 | log.info("Cannot backup missing file {!r}".format(name)) |
| 393 | + |
| 394 | + |
| 395 | +class setup_tests(Command): |
| 396 | + """ |
| 397 | + Sets up security configuration. |
| 398 | +
|
| 399 | + * Run setup_security and create_bucket_types |
| 400 | + """ |
| 401 | + |
| 402 | + description = "create bucket types and security settings for testing" |
| 403 | + |
| 404 | + user_options = create_bucket_types.user_options + setup_security.user_options |
| 405 | + |
| 406 | + def initialize_options(self): |
| 407 | + self.riak_admin = None |
| 408 | + self.username = None |
| 409 | + self.password = None |
| 410 | + pass |
| 411 | + |
| 412 | + def finalize_options(self): |
| 413 | + bucket = self.distribution.get_command_obj('create_bucket_types') |
| 414 | + bucket.riak_admin = self.riak_admin |
| 415 | + security = self.distribution.get_command_obj('setup_security') |
| 416 | + security.riak_admin = self.riak_admin |
| 417 | + security.username = self.username |
| 418 | + security.password = self.password |
| 419 | + pass |
| 420 | + |
| 421 | + def run(self): |
| 422 | + # Run all relevant sub-commands. |
| 423 | + for cmd_name in self.get_sub_commands(): |
| 424 | + self.run_command(cmd_name) |
| 425 | + |
| 426 | + sub_commands = [('create_bucket_types', None), |
| 427 | + ('setup_security', None) |
| 428 | + ] |
0 commit comments