Exemple #1
0
    def convert(self, value, param, ctx):
        from aiida.manage.configuration.options import get_option, get_option_names

        if value not in get_option_names():
            raise click.BadParameter('{} is not a valid configuration option'.format(value))

        return get_option(value)
Exemple #2
0
 def test_options(self):
     """Test that all defined options can be converted into Option namedtuples."""
     for option_name in get_option_names():
         option = get_option(option_name)
         self.assertEqual(option.name, option_name)
         self.assertIsInstance(option.description, str)
         option.valid_type  # pylint: disable=pointless-statement
         option.default  # pylint: disable=pointless-statement
Exemple #3
0
    def complete(self, ctx, incomplete):  # pylint: disable=unused-argument,no-self-use
        """
        Return possible completions based on an incomplete value

        :returns: list of tuples of valid entry points (matching incomplete) and a description
        """
        from aiida.manage.configuration.options import get_option_names

        return [(option_name, '') for option_name in get_option_names() if option_name.startswith(incomplete)]
Exemple #4
0
    def test_get_option(self):
        """Test `get_option` function."""
        with self.assertRaises(ConfigurationError):
            get_option('no_existing_option')

        option_name = get_option_names()[0]
        option = get_option(option_name)
        self.assertIsInstance(option, Option)
        self.assertEqual(option.name, option_name)
Exemple #5
0
 def test_get_option_names(self):
     """Test `get_option_names` function."""
     self.assertEqual(get_option_names(), CONFIG_OPTIONS.keys())
Exemple #6
0
 def test_get_option_names(self):
     """Test `get_option_names` function."""
     self.assertIsInstance(get_option_names(), list)
     self.assertEqual(len(get_option_names()), 26)