def test_complete_amibguity(self): """ Test the complete method which is used for auto completion when the supported groups share an entry point with the same name, which can lead to ambiguity. In this case the autocomplete should always return the possibilites in the FULL entry point string format. When the user tries to autocomplete """ param = PluginParamType(group=('aiida.tools.dbexporters', 'aiida.tools.dbimporters')) entry_point_full_exporters = 'aiida.tools.dbexporters:tcod' entry_point_full_importers = 'aiida.tools.dbimporters:tcod' options = [ item[0] for item in param.complete(None, 'aiida.tools.dbexporters:tc') ] self.assertIn(entry_point_full_exporters, options) options = [ item[0] for item in param.complete(None, 'aiida.tools.dbexporters:tcod') ] self.assertIn(entry_point_full_exporters, options) options = [ item[0] for item in param.complete(None, 'aiida.tools.dbimporters:tc') ] self.assertIn(entry_point_full_importers, options) options = [ item[0] for item in param.complete(None, 'aiida.tools.dbimporters:tcod') ] self.assertIn(entry_point_full_importers, options) # PARTIAL or MINIMAL string formats will not be autocompleted options = [ item[0] for item in param.complete(None, 'tools.dbimporters:tc') ] self.assertNotIn(entry_point_full_exporters, options) self.assertNotIn(entry_point_full_importers, options) options = [ item[0] for item in param.complete(None, 'tools.dbimporters:tcod') ] self.assertNotIn(entry_point_full_exporters, options) self.assertNotIn(entry_point_full_importers, options) options = [item[0] for item in param.complete(None, 'tc')] self.assertNotIn(entry_point_full_exporters, options) self.assertNotIn(entry_point_full_importers, options) options = [item[0] for item in param.complete(None, 'tcod')] self.assertNotIn(entry_point_full_exporters, options) self.assertNotIn(entry_point_full_importers, options)
def test_complete_single_group(self): """ Test the complete method which is used for auto completion when there is only a single valid group, which means there should never be ambiguity and specifying a full entry point string is not necessary, however, when the user decides to user either a FULL or PARTIAL string anyway, the completion should match that syntax """ param = PluginParamType(group=('transports')) entry_point_minimal = 'ssh' entry_point_partial = 'transports:ssh' entry_point_full = 'aiida.transports:ssh' options = [item[0] for item in param.complete(None, 'ss')] self.assertIn(entry_point_minimal, options) options = [item[0] for item in param.complete(None, 'ssh')] self.assertIn(entry_point_minimal, options) options = [item[0] for item in param.complete(None, 'transports:ss')] self.assertIn(entry_point_partial, options) options = [item[0] for item in param.complete(None, 'transports:ssh')] self.assertIn(entry_point_partial, options) options = [ item[0] for item in param.complete(None, 'aiida.transports:ss') ] self.assertIn(entry_point_full, options) options = [ item[0] for item in param.complete(None, 'aiida.transports:ssh') ] self.assertIn(entry_point_full, options)