Skip to content

Commit

Permalink
Test template + link everything
Browse files Browse the repository at this point in the history
  • Loading branch information
DifferentialOrange committed Feb 18, 2022
1 parent 27ba6cd commit aade123
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 127 deletions.
29 changes: 7 additions & 22 deletions tarantool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@
# pylint: disable=C0301,W0105,W0401,W0614

from tarantool.connection import Connection
from tarantool.connection_pool import ConnectionPool
from tarantool.const import (RECONNECT_DELAY, RECONNECT_MAX_ATTEMPTS,
SOCKET_TIMEOUT)
from tarantool.error import DatabaseError, Error, NetworkError, NetworkWarning
from tarantool.mesh_connection import MeshConnection
from tarantool.const import (
SOCKET_TIMEOUT,
RECONNECT_MAX_ATTEMPTS,
RECONNECT_DELAY,
)

from tarantool.error import (
Error,
DatabaseError,
NetworkError,
NetworkWarning,
)

from tarantool.schema import (
Schema,
SchemaError
)

from tarantool.utils import (
ENCODING_DEFAULT
)
from tarantool.schema import Schema, SchemaError
from tarantool.utils import ENCODING_DEFAULT

__version__ = "0.7.1"

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

__all__ = ['connect', 'Connection', 'connectmesh', 'MeshConnection', 'Schema',
'Error', 'DatabaseError', 'NetworkError', 'NetworkWarning',
'SchemaError', 'dbapi']
'SchemaError', 'ConnectionPool', 'dbapi']
94 changes: 30 additions & 64 deletions tarantool/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,44 @@
This module provides low-level API for Tarantool
'''

import os
import time
import abc
import ctypes
import ctypes.util
import errno
import os
import socket
import time

import msgpack
import tarantool.error
from tarantool.const import (CONNECTION_TIMEOUT, IPROTO_GREETING_SIZE,
ITERATOR_ALL, ITERATOR_EQ, RECONNECT_DELAY,
RECONNECT_MAX_ATTEMPTS, REQUEST_TYPE_ERROR,
REQUEST_TYPE_OK, SOCKET_TIMEOUT)
from tarantool.error import (ConfigurationError, DatabaseError, DataError,
Error, IntegrityError, InterfaceError,
InternalError, NetworkError, NetworkWarning,
NotSupportedError, OperationalError,
ProgrammingError, SchemaError,
SchemaReloadException, Warning, warn)
from tarantool.request import (Request, RequestAuthenticate, # RequestOK,
RequestCall, RequestDelete, RequestEval,
RequestExecute, RequestInsert, RequestJoin,
RequestPing, RequestReplace, RequestSelect,
RequestSubscribe, RequestUpdate, RequestUpsert)
from tarantool.response import Response
from tarantool.schema import Schema
from tarantool.space import Space
from tarantool.utils import (ENCODING_DEFAULT, check_key, greeting_decode,
string_types, version_id)

import ctypes
import ctypes.util
try:
from ctypes import c_ssize_t
except ImportError:
from ctypes import c_longlong as c_ssize_t

import msgpack

import tarantool.error
from tarantool.response import Response
from tarantool.request import (
Request,
# RequestOK,
RequestCall,
RequestDelete,
RequestEval,
RequestInsert,
RequestJoin,
RequestReplace,
RequestPing,
RequestSelect,
RequestSubscribe,
RequestUpdate,
RequestUpsert,
RequestAuthenticate,
RequestExecute
)
from tarantool.space import Space
from tarantool.const import (
CONNECTION_TIMEOUT,
SOCKET_TIMEOUT,
RECONNECT_MAX_ATTEMPTS,
RECONNECT_DELAY,
REQUEST_TYPE_OK,
REQUEST_TYPE_ERROR,
IPROTO_GREETING_SIZE,
ITERATOR_EQ,
ITERATOR_ALL
)
from tarantool.error import (
Error,
NetworkError,
DatabaseError,
InterfaceError,
ConfigurationError,
SchemaError,
NetworkWarning,
OperationalError,
DataError,
IntegrityError,
InternalError,
ProgrammingError,
NotSupportedError,
SchemaReloadException,
Warning,
warn
)
from tarantool.schema import Schema
from tarantool.utils import (
check_key,
greeting_decode,
version_id,
string_types,
ENCODING_DEFAULT,
)

# Based on https://realpython.com/python-interface/
class ConnectionInterface(metaclass=abc.ABCMeta):
@classmethod
Expand Down Expand Up @@ -129,11 +95,11 @@ def eval(self, expr, *args, **kwargs):
raise NotImplementedError

@abc.abstractmethod
def replace(self, space_name, values, **kwargs):
def replace(self, space_name, values):
raise NotImplementedError

@abc.abstractmethod
def insert(self, space_name, values, **kwargs):
def insert(self, space_name, values):
raise NotImplementedError

@abc.abstractmethod
Expand Down
9 changes: 4 additions & 5 deletions tarantool/connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ def __init__(self,
encoding=ENCODING_DEFAULT,
call_16=False,
connection_timeout=CONNECTION_TIMEOUT,
strategy_class=RoundRobinStrategy,):
strategy_class=RoundRobinStrategy,
cluster_discovery_function=None,
cluster_discovery_delay=CLUSTER_DISCOVERY_DELAY,):
if not isinstance(addrs, list) or len(addrs) == 0:
raise ConfigurationError("addrs must be non-empty list")

Expand Down Expand Up @@ -244,9 +246,6 @@ def eval(self, expr, *args, **kwargs):
def replace(self, space_name, values):
raise NotImplementedError

def authenticate(self, user, password):
raise NotImplementedError

def insert(self, space_name, values):
raise NotImplementedError

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

def execute(self, query, params):
def execute(self, query, params, **kwargs):
raise NotImplementedError
25 changes: 6 additions & 19 deletions tarantool/mesh_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,14 @@

import time


from tarantool.connection import Connection
from tarantool.error import (
warn,
NetworkError,
DatabaseError,
ConfigurationError,
ClusterDiscoveryWarning,
)
from tarantool.const import (CLUSTER_DISCOVERY_DELAY, CONNECTION_TIMEOUT,
RECONNECT_DELAY, RECONNECT_MAX_ATTEMPTS,
SOCKET_TIMEOUT)
from tarantool.error import (ClusterDiscoveryWarning, ConfigurationError,
DatabaseError, NetworkError, warn)
from tarantool.request import RequestCall
from tarantool.utils import ENCODING_DEFAULT
from tarantool.const import (
CONNECTION_TIMEOUT,
SOCKET_TIMEOUT,
RECONNECT_MAX_ATTEMPTS,
RECONNECT_DELAY,
CLUSTER_DISCOVERY_DELAY,
)

from tarantool.request import (
RequestCall
)

try:
string_types = basestring
Expand Down
22 changes: 11 additions & 11 deletions test/suites/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import os
import unittest

__tmp = os.getcwd()
os.chdir(os.path.abspath(os.path.dirname(__file__)))

from .test_schema import TestSuite_Schema_UnicodeConnection
from .test_schema import TestSuite_Schema_BinaryConnection
from .test_dbapi import TestSuite_DBAPI
from .test_dml import TestSuite_Request
from .test_execute import TestSuite_Execute
from .test_mesh import TestSuite_Mesh
from .test_pool import TestSuite_Pool
from .test_protocol import TestSuite_Protocol
from .test_reconnect import TestSuite_Reconnect
from .test_mesh import TestSuite_Mesh
from .test_execute import TestSuite_Execute
from .test_dbapi import TestSuite_DBAPI
from .test_schema import (TestSuite_Schema_BinaryConnection,
TestSuite_Schema_UnicodeConnection)

__tmp = os.getcwd()
os.chdir(os.path.abspath(os.path.dirname(__file__)))


test_cases = (TestSuite_Schema_UnicodeConnection,
TestSuite_Schema_BinaryConnection,
TestSuite_Request, TestSuite_Protocol, TestSuite_Reconnect,
TestSuite_Mesh, TestSuite_Execute, TestSuite_DBAPI)
TestSuite_Mesh, TestSuite_Execute, TestSuite_DBAPI, TestSuite_Pool)

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


os.chdir(__tmp)


10 changes: 4 additions & 6 deletions test/suites/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import unittest
import warnings
from time import sleep

import tarantool
from tarantool.error import (
NetworkError,
ConfigurationError,
NetworkWarning,
ClusterDiscoveryWarning,
)
from tarantool.error import (ClusterDiscoveryWarning, ConfigurationError,
NetworkError, NetworkWarning)

from .lib.tarantool_server import TarantoolServer


Expand Down

0 comments on commit aade123

Please sign in to comment.