def test_delete_purchases_verbose_dry_run(groc_connection, groc_db_url, connection_function_scope, stores_and_purchases_function_scope): groc_connection.return_value = connection_function_scope # Get a purchase id cursor = groc_connection().cursor() res = cursor.execute('SELECT id FROM purchase LIMIT 1;').fetchone() id = (res['id']) g = Groc() purchases = g.select_by_id((id, )) table = from_db_cursor(purchases) table.align['store'] = 'r' table.align['total'] = 'r' table.align['description'] = 'l' # Output this string regardless of dry-run or not delete_msg = f'Deleting purchases with id(s) {id}.' runner = CliRunner() result = runner.invoke(groc_cli, ['delete', '--id', id, '--verbose', '--dry-run']) assert result.exit_code == 0 assert result.output == f'{table}\n{delete_msg}\n'
def test_select_by_id( mock_select_id, mock_create_connection, mock_os_path_expanduser ): g = Groc() g.select_by_id((1, 2, 3)) mock_select_id.assert_called_with('some-connection', (1, 2, 3))