Beispiel #1
0
 def setUpClass(cls):
     cls.db_connection = db.DatabaseConnection(":memory:")
     index_generator = generator.IndexGenerator([
         ModelIndexer(cls.db_connection),
         APICallIndexer(cls.db_connection)
     ], )
     driver = clidriver.create_clidriver()
     driver.session.register('building-command-table.main',
                             _ddb_only_command_table)
     index_generator.generate_index(driver)
Beispiel #2
0
 def setUp(self):
     self.session = mock.Mock(spec=Session)
     self.aws_command = DummyCommand(
         # The CLIDriver doesn't actually have a ``name`` property,
         # but it should probably be 'aws'.
         command_name=None,
         arg_table={
             'region': DummyArg('region'),
             'endpoint-url': DummyArg('endpoint-url'),
         },
         subcommand_table={
             'ec2':
             DummyCommand(command_name='ec2',
                          subcommand_table={
                              'describe-instances':
                              DummyCommand('describe-instances',
                                           arg_table={
                                               'instance-ids':
                                               DummyArg('instance-ids'),
                                               'filters':
                                               DummyArg('filters',
                                                        'list',
                                                        nargs='+'),
                                           }),
                              'run-instances':
                              DummyCommand('run-instances'),
                          }),
             's3':
             DummyCommand(command_name='s3',
                          subcommand_table={
                              'list-objects': DummyCommand('list-objects'),
                              'put-object': DummyCommand('put-object'),
                          })
         })
     # Ideally we just use ':memory:', but that's for
     # a specific sqlite3 connection so we'd have to
     # update our interfaces to return/accept a db connection.
     # I'd prefer not to have db connections as part of the
     # indexing interface.
     self.temp_dir = tempfile.mkdtemp()
     self.tempfile = os.path.join(self.temp_dir, 'temp.db')
     self.db_conn = db.DatabaseConnection(self.tempfile)
     self.indexer = indexer.ModelIndexer(self.db_conn)
     self.query = model.ModelIndex(self.tempfile)
Beispiel #3
0
 def _get_db_connection(self):
     if self._db_connection is None:
         self._db_connection = db.DatabaseConnection(
             self._db_filename)
     return self._db_connection
Beispiel #4
0
def create_server_side_completer(index_filename):
    return servercomp.ServerSideCompleter(
        model.DBCompletionLookup(
            db.DatabaseConnection(index_filename)
        ),
        servercomp.LazyClientCreator())
Beispiel #5
0
 def setUp(self):
     self.db_connection = db.DatabaseConnection(":memory:")