def parse_args(args): """Parse arguments and return them """ parser = argparse.ArgumentParser( description='fuel-upgrade is an upgrade system for fuel-master node') parser.add_argument( 'systems', choices=SUPPORTED_SYSTEMS.keys(), nargs='+', help='systems to upgrade') parser.add_argument( '--src', required=True, help='path to update file') parser.add_argument( '--no-checker', action='store_true', help='do not check before upgrade') parser.add_argument( '--no-rollback', action='store_true', help='do not rollback in case of errors') parser.add_argument( '--password', help="admin user password") rv = parser.parse_args(args) # check input systems for compatibility for uncompatible_systems in UNCOMPATIBLE_SYSTEMS: if all(u_system in rv.systems for u_system in uncompatible_systems): parser.error( 'the following systems are incompatible and can not be' 'used at the same time: "{0}"'.format( ', '.join(uncompatible_systems) ) ) # check input systems have no duplicates if len(rv.systems) != len(set(rv.systems)): parser.error( 'the following systems are listed more than one times: "{0}"' .format(', '.join(sorted(utils.get_non_unique(rv.systems)))) ) return rv
def test_empty_if_empty_input(self): self.assertEqual([], list(utils.get_non_unique([])))
def test_empty_if_no_duplicates(self): self.assertEqual([], list(utils.get_non_unique(six.moves.range(3))))
def test_get_duplicates(self): self.assertItemsEqual([2, 3], utils.get_non_unique([2, 2, 2, 3, 3, 1]))