Esempio n. 1
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]
Esempio n. 2
0
 def list_tables(self):
     """
     Runs the ``\dt`` command and returns a list of column values with
     information about all tables in the database.
     """
     lines = output_lines(self.exec_psql('\dt'))
     return [line.split('|') for line in lines]
Esempio n. 3
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
Esempio n. 4
0
    def test_access_logs(self, nginx_container):
        """
        When we make a request against Nginx, the request is logged to the
        access log which is output to stdout.
        """
        old_logs = output_lines(nginx_container.get_logs(stderr=False))

        client = nginx_container.http_client()
        response = client.get("/static/icecream/images/background.gif")

        # Wait a moment for the access log to be recoreded
        time.sleep(0.1)
        logs = output_lines(nginx_container.get_logs(stderr=False))
        new_logs = logs[len(old_logs):]

        [log_line] = new_logs
        assert ("GET /static/icecream/images/background.gif HTTP/1.1"
                in log_line)
        assert str(response.status_code) in log_line
Esempio n. 5
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]
Esempio n. 6
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]
Esempio n. 7
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'))
Esempio n. 8
0
 def exec_django_admin(self, *args):
     return output_lines(self.inner().exec_run(["django-admin"] + args))
Esempio n. 9
0
 def test_custom_encoding(self):
     """String lines can be parsed using a custom encoding."""
     self.assertEqual(output_lines(b'\xe1', encoding='latin1'), ['á'])
Esempio n. 10
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'])
Esempio n. 11
0
 def test_bytes(self):
     """String lines are parsed from output bytes."""
     self.assertEqual(output_lines(b'foo\nbar\n'), ['foo', 'bar'])