def list_databases(self): """ Runs the ``\\list`` command and returns a list of column values with information about all databases. """ lines = output_lines(self.exec_psql('\\list')) return [line.split('|') for line in lines]
def test_exec_nginx(self, nginx): """ We can run an Nginx command inside a running container using ``exec_nginx()``. """ output = output_lines(nginx.exec_nginx(['-V'])) assert output[0].startswith('nginx version: nginx/')
def list_users(self): """ Runs the ``\\du`` command and returns a list of column values with information about all user roles. """ lines = output_lines(self.exec_psql('\\du')) return [line.split('|') for line in lines]
def list_keys(self, pattern='*', db=0): """ Run the ``KEYS`` command and return the list of matching keys. :param pattern: the pattern to filter keys by (default ``*``) :param db: the db number to query (default ``0``) """ lines = output_lines(self.exec_redis_cli('KEYS', [pattern], db=db)) return [] if lines == [''] else lines
def exec_conf_check(self, conf, pattern): return output_lines( self.exec( 'cat', conf, '|', 'grep', '"' + pattern + '"', ))
def list_users(self): """ Run the ``list_users`` command and return a list of tuples describing the users. :return: A list of 2-element tuples. The first element is the username, the second a list of tags for the user. """ lines = output_lines(self.exec_rabbitmqctl_list('users')) return [_parse_rabbitmq_user(line) for line in lines]
def list_queues(self): """ Run the ``list_queues`` command (for the default vhost) and return a list of tuples describing the queues. :return: A list of 2-element tuples. The first element is the queue name, the second is the current queue size. """ lines = output_lines( self.exec_rabbitmqctl_list('queues', ['-p', self.vhost])) return [tuple(line.split(None, 1)) for line in lines]
def list_vhosts(self): """ Run the ``list_vhosts`` command and return a list of vhost names. """ return output_lines(self.exec_rabbitmqctl_list('vhosts'))
def exec_file_exists(self, file): output = output_lines(self.exec('[ -f ' + file + ' ] && echo 1 || 0')) return output[0] == '1'
def test_bytes(self): """String lines are parsed from output bytes.""" self.assertEqual(output_lines(b'foo\nbar\n'), ['foo', 'bar'])
def test_custom_encoding(self): """String lines can be parsed using a custom encoding.""" self.assertEqual(output_lines(b'\xe1', encoding='latin1'), ['á'])
def test_exec_result(self): """String lines are parsed from an ExecResult.""" self.assertEqual(output_lines(ExecResult(128, b'foo\r\nbar\r\n')), ['foo', 'bar'])