Introduced deterministic order in connection export (#11670)
The tests for connection export failed when CLI tests are run in isolation. The problem was with non-deterministic sequence of returned rows from connection export query. Rather than fixing the test to accept the non-deterministic sequence, it is better idea to return them always in the connection_id order. This does not change functionality and is backwards compatible, but at the same time it gives stability in the export, which might be important if someone uses export to determine for example if some connections were added/removed.
This commit is contained in:
Родитель
03730891cb
Коммит
b5d1ab9409
|
@ -154,7 +154,7 @@ def connections_export(args):
|
|||
f"The file must have the extension {', '.join(allowed_formats)}"
|
||||
raise SystemExit(msg)
|
||||
|
||||
connections = session.query(Connection).all()
|
||||
connections = session.query(Connection).order_by(Connection.conn_id).all()
|
||||
msg = _format_connections(connections, filetype)
|
||||
args.file.write(msg)
|
||||
|
||||
|
|
|
@ -216,9 +216,10 @@ class TestCliExportConnections(unittest.TestCase):
|
|||
mock_splittext):
|
||||
output_filepath = '/tmp/connections.json'
|
||||
|
||||
def my_side_effect():
|
||||
def my_side_effect(_):
|
||||
raise Exception("dummy exception")
|
||||
mock_session.return_value.__enter__.return_value.query.return_value.all.side_effect = my_side_effect
|
||||
mock_session.return_value.__enter__.return_value.query.return_value.order_by.side_effect = \
|
||||
my_side_effect
|
||||
mock_splittext.return_value = (None, '.json')
|
||||
|
||||
args = self.parser.parse_args([
|
||||
|
|
Загрузка…
Ссылка в новой задаче