Skip to content

Commit aade123

Browse files
Test template + link everything
1 parent 27ba6cd commit aade123

File tree

6 files changed

+62
-127
lines changed

6 files changed

+62
-127
lines changed

tarantool/__init__.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,13 @@
22
# pylint: disable=C0301,W0105,W0401,W0614
33

44
from tarantool.connection import Connection
5+
from tarantool.connection_pool import ConnectionPool
6+
from tarantool.const import (RECONNECT_DELAY, RECONNECT_MAX_ATTEMPTS,
7+
SOCKET_TIMEOUT)
8+
from tarantool.error import DatabaseError, Error, NetworkError, NetworkWarning
59
from tarantool.mesh_connection import MeshConnection
6-
from tarantool.const import (
7-
SOCKET_TIMEOUT,
8-
RECONNECT_MAX_ATTEMPTS,
9-
RECONNECT_DELAY,
10-
)
11-
12-
from tarantool.error import (
13-
Error,
14-
DatabaseError,
15-
NetworkError,
16-
NetworkWarning,
17-
)
18-
19-
from tarantool.schema import (
20-
Schema,
21-
SchemaError
22-
)
23-
24-
from tarantool.utils import (
25-
ENCODING_DEFAULT
26-
)
10+
from tarantool.schema import Schema, SchemaError
11+
from tarantool.utils import ENCODING_DEFAULT
2712

2813
__version__ = "0.7.1"
2914

@@ -75,4 +60,4 @@ def connectmesh(addrs=({'host': 'localhost', 'port': 3301},), user=None,
7560

7661
__all__ = ['connect', 'Connection', 'connectmesh', 'MeshConnection', 'Schema',
7762
'Error', 'DatabaseError', 'NetworkError', 'NetworkWarning',
78-
'SchemaError', 'dbapi']
63+
'SchemaError', 'ConnectionPool', 'dbapi']

tarantool/connection.py

+30-64
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,44 @@
44
This module provides low-level API for Tarantool
55
'''
66

7-
import os
8-
import time
97
import abc
8+
import ctypes
9+
import ctypes.util
1010
import errno
11+
import os
1112
import socket
13+
import time
14+
15+
import msgpack
16+
import tarantool.error
17+
from tarantool.const import (CONNECTION_TIMEOUT, IPROTO_GREETING_SIZE,
18+
ITERATOR_ALL, ITERATOR_EQ, RECONNECT_DELAY,
19+
RECONNECT_MAX_ATTEMPTS, REQUEST_TYPE_ERROR,
20+
REQUEST_TYPE_OK, SOCKET_TIMEOUT)
21+
from tarantool.error import (ConfigurationError, DatabaseError, DataError,
22+
Error, IntegrityError, InterfaceError,
23+
InternalError, NetworkError, NetworkWarning,
24+
NotSupportedError, OperationalError,
25+
ProgrammingError, SchemaError,
26+
SchemaReloadException, Warning, warn)
27+
from tarantool.request import (Request, RequestAuthenticate, # RequestOK,
28+
RequestCall, RequestDelete, RequestEval,
29+
RequestExecute, RequestInsert, RequestJoin,
30+
RequestPing, RequestReplace, RequestSelect,
31+
RequestSubscribe, RequestUpdate, RequestUpsert)
32+
from tarantool.response import Response
33+
from tarantool.schema import Schema
34+
from tarantool.space import Space
35+
from tarantool.utils import (ENCODING_DEFAULT, check_key, greeting_decode,
36+
string_types, version_id)
1237

13-
import ctypes
14-
import ctypes.util
1538
try:
1639
from ctypes import c_ssize_t
1740
except ImportError:
1841
from ctypes import c_longlong as c_ssize_t
1942

20-
import msgpack
2143

22-
import tarantool.error
23-
from tarantool.response import Response
24-
from tarantool.request import (
25-
Request,
26-
# RequestOK,
27-
RequestCall,
28-
RequestDelete,
29-
RequestEval,
30-
RequestInsert,
31-
RequestJoin,
32-
RequestReplace,
33-
RequestPing,
34-
RequestSelect,
35-
RequestSubscribe,
36-
RequestUpdate,
37-
RequestUpsert,
38-
RequestAuthenticate,
39-
RequestExecute
40-
)
41-
from tarantool.space import Space
42-
from tarantool.const import (
43-
CONNECTION_TIMEOUT,
44-
SOCKET_TIMEOUT,
45-
RECONNECT_MAX_ATTEMPTS,
46-
RECONNECT_DELAY,
47-
REQUEST_TYPE_OK,
48-
REQUEST_TYPE_ERROR,
49-
IPROTO_GREETING_SIZE,
50-
ITERATOR_EQ,
51-
ITERATOR_ALL
52-
)
53-
from tarantool.error import (
54-
Error,
55-
NetworkError,
56-
DatabaseError,
57-
InterfaceError,
58-
ConfigurationError,
59-
SchemaError,
60-
NetworkWarning,
61-
OperationalError,
62-
DataError,
63-
IntegrityError,
64-
InternalError,
65-
ProgrammingError,
66-
NotSupportedError,
67-
SchemaReloadException,
68-
Warning,
69-
warn
70-
)
71-
from tarantool.schema import Schema
72-
from tarantool.utils import (
73-
check_key,
74-
greeting_decode,
75-
version_id,
76-
string_types,
77-
ENCODING_DEFAULT,
78-
)
44+
7945
# Based on https://realpython.com/python-interface/
8046
class ConnectionInterface(metaclass=abc.ABCMeta):
8147
@classmethod
@@ -129,11 +95,11 @@ def eval(self, expr, *args, **kwargs):
12995
raise NotImplementedError
13096

13197
@abc.abstractmethod
132-
def replace(self, space_name, values, **kwargs):
98+
def replace(self, space_name, values):
13399
raise NotImplementedError
134100

135101
@abc.abstractmethod
136-
def insert(self, space_name, values, **kwargs):
102+
def insert(self, space_name, values):
137103
raise NotImplementedError
138104

139105
@abc.abstractmethod

tarantool/connection_pool.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def __init__(self,
144144
encoding=ENCODING_DEFAULT,
145145
call_16=False,
146146
connection_timeout=CONNECTION_TIMEOUT,
147-
strategy_class=RoundRobinStrategy,):
147+
strategy_class=RoundRobinStrategy,
148+
cluster_discovery_function=None,
149+
cluster_discovery_delay=CLUSTER_DISCOVERY_DELAY,):
148150
if not isinstance(addrs, list) or len(addrs) == 0:
149151
raise ConfigurationError("addrs must be non-empty list")
150152

@@ -244,9 +246,6 @@ def eval(self, expr, *args, **kwargs):
244246
def replace(self, space_name, values):
245247
raise NotImplementedError
246248

247-
def authenticate(self, user, password):
248-
raise NotImplementedError
249-
250249
def insert(self, space_name, values):
251250
raise NotImplementedError
252251

@@ -265,5 +264,5 @@ def ping(self, notime):
265264
def select(self, space_name, key, **kwargs):
266265
raise NotImplementedError
267266

268-
def execute(self, query, params):
267+
def execute(self, query, params, **kwargs):
269268
raise NotImplementedError

tarantool/mesh_connection.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,14 @@
66

77
import time
88

9-
109
from tarantool.connection import Connection
11-
from tarantool.error import (
12-
warn,
13-
NetworkError,
14-
DatabaseError,
15-
ConfigurationError,
16-
ClusterDiscoveryWarning,
17-
)
10+
from tarantool.const import (CLUSTER_DISCOVERY_DELAY, CONNECTION_TIMEOUT,
11+
RECONNECT_DELAY, RECONNECT_MAX_ATTEMPTS,
12+
SOCKET_TIMEOUT)
13+
from tarantool.error import (ClusterDiscoveryWarning, ConfigurationError,
14+
DatabaseError, NetworkError, warn)
15+
from tarantool.request import RequestCall
1816
from tarantool.utils import ENCODING_DEFAULT
19-
from tarantool.const import (
20-
CONNECTION_TIMEOUT,
21-
SOCKET_TIMEOUT,
22-
RECONNECT_MAX_ATTEMPTS,
23-
RECONNECT_DELAY,
24-
CLUSTER_DISCOVERY_DELAY,
25-
)
26-
27-
from tarantool.request import (
28-
RequestCall
29-
)
3017

3118
try:
3219
string_types = basestring

test/suites/__init__.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
import os
22
import unittest
33

4-
__tmp = os.getcwd()
5-
os.chdir(os.path.abspath(os.path.dirname(__file__)))
6-
7-
from .test_schema import TestSuite_Schema_UnicodeConnection
8-
from .test_schema import TestSuite_Schema_BinaryConnection
4+
from .test_dbapi import TestSuite_DBAPI
95
from .test_dml import TestSuite_Request
6+
from .test_execute import TestSuite_Execute
7+
from .test_mesh import TestSuite_Mesh
8+
from .test_pool import TestSuite_Pool
109
from .test_protocol import TestSuite_Protocol
1110
from .test_reconnect import TestSuite_Reconnect
12-
from .test_mesh import TestSuite_Mesh
13-
from .test_execute import TestSuite_Execute
14-
from .test_dbapi import TestSuite_DBAPI
11+
from .test_schema import (TestSuite_Schema_BinaryConnection,
12+
TestSuite_Schema_UnicodeConnection)
13+
14+
__tmp = os.getcwd()
15+
os.chdir(os.path.abspath(os.path.dirname(__file__)))
16+
1517

1618
test_cases = (TestSuite_Schema_UnicodeConnection,
1719
TestSuite_Schema_BinaryConnection,
1820
TestSuite_Request, TestSuite_Protocol, TestSuite_Reconnect,
19-
TestSuite_Mesh, TestSuite_Execute, TestSuite_DBAPI)
21+
TestSuite_Mesh, TestSuite_Execute, TestSuite_DBAPI, TestSuite_Pool)
2022

2123
def load_tests(loader, tests, pattern):
2224
suite = unittest.TestSuite()
@@ -26,5 +28,3 @@ def load_tests(loader, tests, pattern):
2628

2729

2830
os.chdir(__tmp)
29-
30-

test/suites/test_mesh.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import unittest
77
import warnings
88
from time import sleep
9+
910
import tarantool
10-
from tarantool.error import (
11-
NetworkError,
12-
ConfigurationError,
13-
NetworkWarning,
14-
ClusterDiscoveryWarning,
15-
)
11+
from tarantool.error import (ClusterDiscoveryWarning, ConfigurationError,
12+
NetworkError, NetworkWarning)
13+
1614
from .lib.tarantool_server import TarantoolServer
1715

1816

0 commit comments

Comments
 (0)