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_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]
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 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
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_django_admin(self, *args): return output_lines(self.inner().exec_run(["django-admin"] + args))
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'])
def test_bytes(self): """String lines are parsed from output bytes.""" self.assertEqual(output_lines(b'foo\nbar\n'), ['foo', 'bar'])