From ed013bc6e05660c4f399e6af80d816d58b8ae5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Fri, 26 Mar 2021 12:49:40 +0100 Subject: [PATCH] Fix tests for Python 3.5 --- tests/unit/data/client/test_sql_client.py | 25 ++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/unit/data/client/test_sql_client.py b/tests/unit/data/client/test_sql_client.py index fca8600e1..b6bb08f6c 100644 --- a/tests/unit/data/client/test_sql_client.py +++ b/tests/unit/data/client/test_sql_client.py @@ -1,5 +1,7 @@ """Unit tests for cartoframes.client.SQLClient""" +from collections import OrderedDict + from cartoframes.auth import Credentials from cartoframes.io.managers.context_manager import ContextManager from cartoframes.data.clients import SQLClient @@ -186,8 +188,10 @@ def test_create_table_no_cartodbfy(self, mocker): """client.SQLClient.create_table""" mocker.patch.object(ContextManager, 'get_schema') mock = mocker.patch.object(ContextManager, 'execute_long_running_query') - SQLClient(self.credentials).create_table( - 'table_name', {'id': 'INT', 'name': 'TEXT'}, cartodbfy=False) + columns = OrderedDict() + columns['id'] = 'INT' + columns['name'] = 'TEXT' + SQLClient(self.credentials).create_table('table_name', columns, cartodbfy=False) mock.assert_called_once_with(''' BEGIN; @@ -201,8 +205,10 @@ def test_create_table_cartodbfy_org_user(self, mocker): """client.SQLClient.create_table cartodbfy: organization user""" mocker.patch.object(ContextManager, 'get_schema', return_value='user_name') mock = mocker.patch.object(ContextManager, 'execute_long_running_query') - SQLClient(self.credentials).create_table( - 'table_name', {'id': 'INT', 'name': 'TEXT'}, if_exists='replace') + columns = OrderedDict() + columns['id'] = 'INT' + columns['name'] = 'TEXT' + SQLClient(self.credentials).create_table('table_name', columns, if_exists='replace') mock.assert_called_once_with(''' BEGIN; @@ -216,8 +222,10 @@ def test_create_table_cartodbfy_public_user(self, mocker): """client.SQLClient.create_table cartodbfy: public user""" mocker.patch.object(ContextManager, 'get_schema', return_value='public') mock = mocker.patch.object(ContextManager, 'execute_long_running_query') - SQLClient(self.credentials).create_table( - 'table_name', {'id': 'INT', 'name': 'TEXT'}, if_exists='fail') + columns = OrderedDict() + columns['id'] = 'INT' + columns['name'] = 'TEXT' + SQLClient(self.credentials).create_table('table_name', columns, if_exists='fail') mock.assert_called_once_with(''' BEGIN; @@ -230,7 +238,10 @@ def test_create_table_cartodbfy_public_user(self, mocker): def test_insert_table(self, mocker): """client.SQLClient.insert_table""" mock = mocker.patch.object(ContextManager, 'execute_long_running_query') - SQLClient(self.credentials).insert_table('table_name', {'id': [0, 1], 'name': ['a', 'b']}) + values = OrderedDict() + values['id'] = [0, 1] + values['name'] = ['a', 'b'] + SQLClient(self.credentials).insert_table('table_name', values) mock.assert_called_once_with(''' INSERT INTO table_name (id,name) VALUES (0,'a'),(1,'b');