Fail if query result does not confront the specified shape, defined in terms of: - number of rows, - number of columns (not checked if there are not rows) - column names.
(self, res: Any, rows: int, columns: int | list[str])
| 1713 | return [list(r.values()) for r in res] |
| 1714 | |
| 1715 | def assert_shape(self, res: Any, rows: int, columns: int | list[str]): |
| 1716 | """ |
| 1717 | Fail if query result does not confront the specified shape, defined in |
| 1718 | terms of: |
| 1719 | - number of rows, |
| 1720 | - number of columns (not checked if there are not rows) |
| 1721 | - column names. |
| 1722 | """ |
| 1723 | |
| 1724 | self.assertEqual(len(res), rows) |
| 1725 | |
| 1726 | if isinstance(columns, int): |
| 1727 | if rows > 0: |
| 1728 | self.assertEqual(len(res[0]), columns) |
| 1729 | elif isinstance(columns, list): |
| 1730 | self.assertListEqual(columns, list(res[0].keys())) |
| 1731 | |
| 1732 | |
| 1733 | class CLITestCaseMixin: |