예제 #1
0
 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]
예제 #2
0
 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/')
예제 #3
0
 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]
예제 #4
0
    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
예제 #5
0
 def exec_conf_check(self, conf, pattern):
     return output_lines(
         self.exec(
             'cat',
             conf,
             '|',
             'grep',
             '"' + pattern + '"',
         ))
예제 #6
0
    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]
예제 #7
0
    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]
예제 #8
0
 def list_vhosts(self):
     """
     Run the ``list_vhosts`` command and return a list of vhost names.
     """
     return output_lines(self.exec_rabbitmqctl_list('vhosts'))
예제 #9
0
 def exec_file_exists(self, file):
     output = output_lines(self.exec('[ -f ' + file + ' ] && echo 1 || 0'))
     return output[0] == '1'
예제 #10
0
 def test_bytes(self):
     """String lines are parsed from output bytes."""
     self.assertEqual(output_lines(b'foo\nbar\n'), ['foo', 'bar'])
예제 #11
0
 def test_custom_encoding(self):
     """String lines can be parsed using a custom encoding."""
     self.assertEqual(output_lines(b'\xe1', encoding='latin1'), ['á'])
예제 #12
0
 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'])