Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
neoppod
Commits
39ae4a2f
Commit
39ae4a2f
authored
Mar 16, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not define exception classes in protocol.py
parent
df2bf949
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
80 additions
and
77 deletions
+80
-77
neo/admin/handler.py
neo/admin/handler.py
+2
-3
neo/lib/connection.py
neo/lib/connection.py
+2
-2
neo/lib/exception.py
neo/lib/exception.py
+27
-0
neo/lib/handler.py
neo/lib/handler.py
+3
-4
neo/lib/node.py
neo/lib/node.py
+2
-2
neo/lib/protocol.py
neo/lib/protocol.py
+0
-28
neo/master/handlers/client.py
neo/master/handlers/client.py
+2
-1
neo/master/handlers/identification.py
neo/master/handlers/identification.py
+2
-2
neo/master/handlers/storage.py
neo/master/handlers/storage.py
+2
-3
neo/master/recovery.py
neo/master/recovery.py
+2
-1
neo/master/transactions.py
neo/master/transactions.py
+2
-1
neo/scripts/neolog.py
neo/scripts/neolog.py
+2
-1
neo/storage/database/importer.py
neo/storage/database/importer.py
+2
-1
neo/storage/database/manager.py
neo/storage/database/manager.py
+2
-1
neo/storage/handlers/__init__.py
neo/storage/handlers/__init__.py
+2
-3
neo/storage/handlers/client.py
neo/storage/handlers/client.py
+2
-1
neo/storage/handlers/identification.py
neo/storage/handlers/identification.py
+2
-2
neo/storage/handlers/initialization.py
neo/storage/handlers/initialization.py
+2
-1
neo/storage/handlers/storage.py
neo/storage/handlers/storage.py
+2
-1
neo/storage/transactions.py
neo/storage/transactions.py
+2
-2
neo/tests/__init__.py
neo/tests/__init__.py
+6
-10
neo/tests/storage/testClientHandler.py
neo/tests/storage/testClientHandler.py
+6
-4
neo/tests/storage/testMasterHandler.py
neo/tests/storage/testMasterHandler.py
+2
-1
neo/tests/testHandler.py
neo/tests/testHandler.py
+2
-2
No files found.
neo/admin/handler.py
View file @
39ae4a2f
...
@@ -15,11 +15,10 @@
...
@@ -15,11 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
NotReadyError
,
PrimaryFailure
,
ProtocolError
from
neo.lib.handler
import
EventHandler
from
neo.lib.handler
import
EventHandler
from
neo.lib.protocol
import
uuid_str
,
\
from
neo.lib.protocol
import
uuid_str
,
NodeTypes
,
Packets
NodeTypes
,
NotReadyError
,
Packets
,
ProtocolError
from
neo.lib.pt
import
PartitionTable
from
neo.lib.pt
import
PartitionTable
from
neo.lib.exception
import
PrimaryFailure
NOT_CONNECTED_MESSAGE
=
'Not connected to a primary master.'
NOT_CONNECTED_MESSAGE
=
'Not connected to a primary master.'
...
...
neo/lib/connection.py
View file @
39ae4a2f
...
@@ -21,9 +21,9 @@ from msgpack.exceptions import OutOfData, UnpackValueError
...
@@ -21,9 +21,9 @@ from msgpack.exceptions import OutOfData, UnpackValueError
from
.
import
attributeTracker
,
logging
from
.
import
attributeTracker
,
logging
from
.connector
import
ConnectorException
,
ConnectorDelayedConnection
from
.connector
import
ConnectorException
,
ConnectorDelayedConnection
from
.exception
import
PacketMalformedError
from
.locking
import
RLock
from
.locking
import
RLock
from
.protocol
import
uuid_str
,
Errors
,
PacketMalformedError
,
Packets
,
\
from
.protocol
import
uuid_str
,
Errors
,
Packets
,
Unpacker
Unpacker
try
:
try
:
msgpack
.
Unpacker
().
read_bytes
(
1
)
msgpack
.
Unpacker
().
read_bytes
(
1
)
...
...
neo/lib/exception.py
View file @
39ae4a2f
...
@@ -29,3 +29,30 @@ class StoppedOperation(NeoException):
...
@@ -29,3 +29,30 @@ class StoppedOperation(NeoException):
class
NodeNotReady
(
NeoException
):
class
NodeNotReady
(
NeoException
):
pass
pass
class
ProtocolError
(
NeoException
):
""" Base class for protocol errors, close the connection """
class
PacketMalformedError
(
ProtocolError
):
pass
class
UnexpectedPacketError
(
ProtocolError
):
pass
class
NotReadyError
(
ProtocolError
):
pass
class
BackendNotImplemented
(
NeoException
):
""" Method not implemented by backend storage """
class
NonReadableCell
(
NeoException
):
"""Read-access to a cell that is actually non-readable
This happens in case of race condition at processing partition table
updates: client's PT is older or newer than storage's. The latter case is
possible because the master must validate any end of replication, which
means that the storage node can't anticipate the PT update (concurrently,
there may be a first tweaks that moves the replicated cell to another node,
and a second one that moves it back).
On such event, the client must retry, preferably another cell.
"""
neo/lib/handler.py
View file @
39ae4a2f
...
@@ -19,10 +19,9 @@ from collections import deque
...
@@ -19,10 +19,9 @@ from collections import deque
from
operator
import
itemgetter
from
operator
import
itemgetter
from
.
import
logging
from
.
import
logging
from
.connection
import
ConnectionClosed
from
.connection
import
ConnectionClosed
from
.exception
import
PrimaryElected
from
.exception
import
(
BackendNotImplemented
,
NonReadableCell
,
NotReadyError
,
from
.protocol
import
(
NodeStates
,
NodeTypes
,
Packets
,
uuid_str
,
PacketMalformedError
,
PrimaryElected
,
ProtocolError
,
UnexpectedPacketError
)
Errors
,
BackendNotImplemented
,
NonReadableCell
,
NotReadyError
,
from
.protocol
import
NodeStates
,
NodeTypes
,
Packets
,
uuid_str
,
Errors
PacketMalformedError
,
ProtocolError
,
UnexpectedPacketError
)
from
.util
import
cached_property
from
.util
import
cached_property
...
...
neo/lib/node.py
View file @
39ae4a2f
...
@@ -18,9 +18,9 @@ import errno, json, os
...
@@ -18,9 +18,9 @@ import errno, json, os
from
time
import
time
from
time
import
time
from
.
import
attributeTracker
,
logging
from
.
import
attributeTracker
,
logging
from
.exception
import
NotReadyError
,
ProtocolError
from
.handler
import
DelayEvent
,
EventQueue
from
.handler
import
DelayEvent
,
EventQueue
from
.protocol
import
formatNodeList
,
uuid_str
,
\
from
.protocol
import
formatNodeList
,
uuid_str
,
NodeTypes
,
NodeStates
NodeTypes
,
NodeStates
,
NotReadyError
,
ProtocolError
class
Node
(
object
):
class
Node
(
object
):
...
...
neo/lib/protocol.py
View file @
39ae4a2f
...
@@ -233,34 +233,6 @@ uuid_str = (lambda ns: lambda uuid:
...
@@ -233,34 +233,6 @@ uuid_str = (lambda ns: lambda uuid:
ns
[
uuid
>>
24
]
+
str
(
uuid
&
0xffffff
)
if
uuid
else
str
(
uuid
)
ns
[
uuid
>>
24
]
+
str
(
uuid
&
0xffffff
)
if
uuid
else
str
(
uuid
)
)({
v
:
str
(
k
)[
0
]
for
k
,
v
in
UUID_NAMESPACES
.
iteritems
()})
)({
v
:
str
(
k
)[
0
]
for
k
,
v
in
UUID_NAMESPACES
.
iteritems
()})
class
ProtocolError
(
Exception
):
""" Base class for protocol errors, close the connection """
class
PacketMalformedError
(
ProtocolError
):
"""Close the connection"""
class
UnexpectedPacketError
(
ProtocolError
):
"""Close the connection"""
class
NotReadyError
(
ProtocolError
):
""" Just close the connection """
class
BackendNotImplemented
(
Exception
):
""" Method not implemented by backend storage """
class
NonReadableCell
(
Exception
):
"""Read-access to a cell that is actually non-readable
This happens in case of race condition at processing partition table
updates: client's PT is older or newer than storage's. The latter case is
possible because the master must validate any end of replication, which
means that the storage node can't anticipate the PT update (concurrently,
there may be a first tweaks that moves the replicated cell to another node,
and a second one that moves it back).
On such event, the client must retry, preferably another cell.
"""
class
Packet
(
object
):
class
Packet
(
object
):
"""
"""
...
...
neo/master/handlers/client.py
View file @
39ae4a2f
...
@@ -15,7 +15,8 @@
...
@@ -15,7 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
neo.lib.handler
import
DelayEvent
from
neo.lib.handler
import
DelayEvent
from
neo.lib.protocol
import
Packets
,
ProtocolError
,
MAX_TID
,
Errors
from
neo.lib.exception
import
ProtocolError
from
neo.lib.protocol
import
Packets
,
MAX_TID
,
Errors
from
..app
import
monotonic_time
from
..app
import
monotonic_time
from
.
import
MasterHandler
from
.
import
MasterHandler
...
...
neo/master/handlers/identification.py
View file @
39ae4a2f
...
@@ -15,10 +15,10 @@
...
@@ -15,10 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
PrimaryElected
from
neo.lib.exception
import
NotReadyError
,
PrimaryElected
,
ProtocolError
from
neo.lib.handler
import
EventHandler
from
neo.lib.handler
import
EventHandler
from
neo.lib.protocol
import
CellStates
,
ClusterStates
,
NodeStates
,
\
from
neo.lib.protocol
import
CellStates
,
ClusterStates
,
NodeStates
,
\
NodeTypes
,
NotReadyError
,
Packets
,
ProtocolError
,
uuid_str
NodeTypes
,
Packets
,
uuid_str
from
..app
import
monotonic_time
from
..app
import
monotonic_time
class
IdentificationHandler
(
EventHandler
):
class
IdentificationHandler
(
EventHandler
):
...
...
neo/master/handlers/storage.py
View file @
39ae4a2f
...
@@ -15,9 +15,8 @@
...
@@ -15,9 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.protocol
import
(
CellStates
,
ClusterStates
,
Packets
,
ProtocolError
,
from
neo.lib.exception
import
ProtocolError
,
StoppedOperation
uuid_str
)
from
neo.lib.protocol
import
CellStates
,
ClusterStates
,
Packets
,
uuid_str
from
neo.lib.exception
import
StoppedOperation
from
neo.lib.pt
import
PartitionTableException
from
neo.lib.pt
import
PartitionTableException
from
neo.lib.util
import
dump
from
neo.lib.util
import
dump
from
.
import
BaseServiceHandler
from
.
import
BaseServiceHandler
...
...
neo/master/recovery.py
View file @
39ae4a2f
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.connection
import
ClientConnection
from
neo.lib.connection
import
ClientConnection
from
neo.lib.protocol
import
Packets
,
ProtocolError
,
ClusterStates
,
NodeStates
from
neo.lib.exception
import
ProtocolError
from
neo.lib.protocol
import
Packets
,
ClusterStates
,
NodeStates
from
.app
import
monotonic_time
from
.app
import
monotonic_time
from
.handlers
import
MasterHandler
from
.handlers
import
MasterHandler
...
...
neo/master/transactions.py
View file @
39ae4a2f
...
@@ -18,8 +18,9 @@ from collections import deque
...
@@ -18,8 +18,9 @@ from collections import deque
from
time
import
time
from
time
import
time
from
struct
import
pack
,
unpack
from
struct
import
pack
,
unpack
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
ProtocolError
from
neo.lib.handler
import
DelayEvent
,
EventQueue
from
neo.lib.handler
import
DelayEvent
,
EventQueue
from
neo.lib.protocol
import
ProtocolError
,
uuid_str
,
ZERO_OID
,
ZERO_TID
from
neo.lib.protocol
import
uuid_str
,
ZERO_OID
,
ZERO_TID
from
neo.lib.util
import
dump
,
u64
,
addTID
,
tidFromTime
from
neo.lib.util
import
dump
,
u64
,
addTID
,
tidFromTime
class
Transaction
(
object
):
class
Transaction
(
object
):
...
...
neo/scripts/neolog.py
View file @
39ae4a2f
...
@@ -162,13 +162,14 @@ class Log(object):
...
@@ -162,13 +162,14 @@ class Log(object):
self
.
_protocol_date
=
date
self
.
_protocol_date
=
date
g
=
{}
g
=
{}
exec
bz2
.
decompress
(
text
)
in
g
exec
bz2
.
decompress
(
text
)
in
g
for
x
in
'uuid_str'
,
'Packets'
,
'PacketMalformedError'
:
for
x
in
'uuid_str'
,
'Packets'
:
setattr
(
self
,
x
,
g
[
x
])
setattr
(
self
,
x
,
g
[
x
])
x
=
{}
x
=
{}
try
:
try
:
Unpacker
=
g
[
'Unpacker'
]
Unpacker
=
g
[
'Unpacker'
]
except
KeyError
:
except
KeyError
:
unpackb
=
None
unpackb
=
None
self
.
PacketMalformedError
=
g
[
'PacketMalformedError'
]
else
:
else
:
from
msgpack
import
ExtraData
,
UnpackException
from
msgpack
import
ExtraData
,
UnpackException
def
unpackb
(
data
):
def
unpackb
(
data
):
...
...
neo/storage/database/importer.py
View file @
39ae4a2f
...
@@ -31,8 +31,9 @@ from ..app import option_defaults
...
@@ -31,8 +31,9 @@ from ..app import option_defaults
from
.
import
buildDatabaseManager
,
DatabaseFailure
from
.
import
buildDatabaseManager
,
DatabaseFailure
from
.manager
import
DatabaseManager
,
Fallback
from
.manager
import
DatabaseManager
,
Fallback
from
neo.lib
import
compress
,
logging
,
patch
,
util
from
neo.lib
import
compress
,
logging
,
patch
,
util
from
neo.lib.exception
import
BackendNotImplemented
from
neo.lib.interfaces
import
implements
from
neo.lib.interfaces
import
implements
from
neo.lib.protocol
import
BackendNotImplemented
,
MAX_TID
from
neo.lib.protocol
import
MAX_TID
patch
.
speedupFileStorageTxnLookup
()
patch
.
speedupFileStorageTxnLookup
()
...
...
neo/storage/database/manager.py
View file @
39ae4a2f
...
@@ -20,8 +20,9 @@ from contextlib import contextmanager
...
@@ -20,8 +20,9 @@ from contextlib import contextmanager
from
copy
import
copy
from
copy
import
copy
from
functools
import
wraps
from
functools
import
wraps
from
neo.lib
import
logging
,
util
from
neo.lib
import
logging
,
util
from
neo.lib.exception
import
NonReadableCell
from
neo.lib.interfaces
import
abstract
,
requires
from
neo.lib.interfaces
import
abstract
,
requires
from
neo.lib.protocol
import
CellStates
,
NonReadableCell
,
MAX_TID
,
ZERO_TID
from
neo.lib.protocol
import
CellStates
,
MAX_TID
,
ZERO_TID
from
.
import
DatabaseFailure
from
.
import
DatabaseFailure
READABLE
=
CellStates
.
UP_TO_DATE
,
CellStates
.
FEEDING
READABLE
=
CellStates
.
UP_TO_DATE
,
CellStates
.
FEEDING
...
...
neo/storage/handlers/__init__.py
View file @
39ae4a2f
...
@@ -17,9 +17,8 @@
...
@@ -17,9 +17,8 @@
import
weakref
import
weakref
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.handler
import
EventHandler
from
neo.lib.handler
import
EventHandler
from
neo.lib.exception
import
PrimaryFailure
,
StoppedOperation
from
neo.lib.exception
import
PrimaryFailure
,
ProtocolError
,
StoppedOperation
from
neo.lib.protocol
import
(
uuid_str
,
from
neo.lib.protocol
import
uuid_str
,
NodeStates
,
NodeTypes
,
Packets
NodeStates
,
NodeTypes
,
Packets
,
ProtocolError
)
class
BaseHandler
(
EventHandler
):
class
BaseHandler
(
EventHandler
):
...
...
neo/storage/handlers/client.py
View file @
39ae4a2f
...
@@ -15,9 +15,10 @@
...
@@ -15,9 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
NonReadableCell
,
ProtocolError
from
neo.lib.handler
import
DelayEvent
from
neo.lib.handler
import
DelayEvent
from
neo.lib.util
import
dump
,
makeChecksum
,
add64
from
neo.lib.util
import
dump
,
makeChecksum
,
add64
from
neo.lib.protocol
import
Packets
,
Errors
,
NonReadableCell
,
ProtocolError
,
\
from
neo.lib.protocol
import
Packets
,
Errors
,
\
ZERO_HASH
,
ZERO_TID
,
INVALID_PARTITION
ZERO_HASH
,
ZERO_TID
,
INVALID_PARTITION
from
..transactions
import
ConflictError
,
NotRegisteredError
from
..transactions
import
ConflictError
,
NotRegisteredError
from
.
import
BaseHandler
from
.
import
BaseHandler
...
...
neo/storage/handlers/identification.py
View file @
39ae4a2f
...
@@ -15,9 +15,9 @@
...
@@ -15,9 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
NotReadyError
,
ProtocolError
from
neo.lib.handler
import
EventHandler
from
neo.lib.handler
import
EventHandler
from
neo.lib.protocol
import
NodeTypes
,
NotReadyError
,
Packets
from
neo.lib.protocol
import
NodeTypes
,
Packets
from
neo.lib.protocol
import
ProtocolError
from
.storage
import
StorageOperationHandler
from
.storage
import
StorageOperationHandler
from
.client
import
ClientOperationHandler
,
ClientReadOnlyOperationHandler
from
.client
import
ClientOperationHandler
,
ClientReadOnlyOperationHandler
...
...
neo/storage/handlers/initialization.py
View file @
39ae4a2f
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
from
.
import
BaseMasterHandler
from
.
import
BaseMasterHandler
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.protocol
import
Packets
,
ProtocolError
,
ZERO_TID
from
neo.lib.exception
import
ProtocolError
from
neo.lib.protocol
import
Packets
,
ZERO_TID
class
InitializationHandler
(
BaseMasterHandler
):
class
InitializationHandler
(
BaseMasterHandler
):
...
...
neo/storage/handlers/storage.py
View file @
39ae4a2f
...
@@ -17,8 +17,9 @@
...
@@ -17,8 +17,9 @@
import
weakref
import
weakref
from
functools
import
wraps
from
functools
import
wraps
from
neo.lib.connection
import
ConnectionClosed
from
neo.lib.connection
import
ConnectionClosed
from
neo.lib.exception
import
ProtocolError
from
neo.lib.handler
import
DelayEvent
,
EventHandler
from
neo.lib.handler
import
DelayEvent
,
EventHandler
from
neo.lib.protocol
import
Errors
,
Packets
,
ProtocolError
,
ZERO_HASH
from
neo.lib.protocol
import
Errors
,
Packets
,
ZERO_HASH
def
checkConnectionIsReplicatorConnection
(
func
):
def
checkConnectionIsReplicatorConnection
(
func
):
def
wrapper
(
self
,
conn
,
*
args
,
**
kw
):
def
wrapper
(
self
,
conn
,
*
args
,
**
kw
):
...
...
neo/storage/transactions.py
View file @
39ae4a2f
...
@@ -16,10 +16,10 @@
...
@@ -16,10 +16,10 @@
from
time
import
time
from
time
import
time
from
neo.lib
import
logging
from
neo.lib
import
logging
from
neo.lib.exception
import
NonReadableCell
,
ProtocolError
from
neo.lib.handler
import
DelayEvent
,
EventQueue
from
neo.lib.handler
import
DelayEvent
,
EventQueue
from
neo.lib.util
import
cached_property
,
dump
from
neo.lib.util
import
cached_property
,
dump
from
neo.lib.protocol
import
Packets
,
ProtocolError
,
NonReadableCell
,
\
from
neo.lib.protocol
import
Packets
,
uuid_str
,
MAX_TID
,
ZERO_TID
uuid_str
,
MAX_TID
,
ZERO_TID
class
ConflictError
(
Exception
):
class
ConflictError
(
Exception
):
"""
"""
...
...
neo/tests/__init__.py
View file @
39ae4a2f
...
@@ -38,8 +38,8 @@ except ImportError:
...
@@ -38,8 +38,8 @@ except ImportError:
from
functools
import
wraps
from
functools
import
wraps
from
inspect
import
isclass
from
inspect
import
isclass
from
.mock
import
Mock
from
.mock
import
Mock
from
neo.lib
import
debug
,
logging
,
protocol
from
neo.lib
import
debug
,
logging
from
neo.lib.protocol
import
NodeTypes
,
Packets
,
UUID_NAMESPACES
from
neo.lib.protocol
import
NodeTypes
,
Packet
,
Packet
s
,
UUID_NAMESPACES
from
neo.lib.util
import
cached_property
from
neo.lib.util
import
cached_property
from
time
import
time
,
sleep
from
time
import
time
,
sleep
from
struct
import
pack
,
unpack
from
struct
import
pack
,
unpack
...
@@ -432,10 +432,6 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -432,10 +432,6 @@ class NeoUnitTestBase(NeoTestBase):
conn
.
connecting
=
False
conn
.
connecting
=
False
return
conn
return
conn
def
checkProtocolErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the ProtocolError exception was raised """
self
.
assertRaises
(
protocol
.
ProtocolError
,
method
,
*
args
,
**
kwargs
)
def
checkAborted
(
self
,
conn
):
def
checkAborted
(
self
,
conn
):
""" Ensure the connection was aborted """
""" Ensure the connection was aborted """
self
.
assertEqual
(
len
(
conn
.
mockGetNamedCalls
(
'abort'
)),
1
)
self
.
assertEqual
(
len
(
conn
.
mockGetNamedCalls
(
'abort'
)),
1
)
...
@@ -461,7 +457,7 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -461,7 +457,7 @@ class NeoUnitTestBase(NeoTestBase):
calls
=
conn
.
mockGetNamedCalls
(
"answer"
)
calls
=
conn
.
mockGetNamedCalls
(
"answer"
)
self
.
assertEqual
(
len
(
calls
),
1
)
self
.
assertEqual
(
len
(
calls
),
1
)
packet
=
calls
.
pop
().
getParam
(
0
)
packet
=
calls
.
pop
().
getParam
(
0
)
self
.
assertTrue
(
isinstance
(
packet
,
protocol
.
Packet
))
self
.
assertTrue
(
isinstance
(
packet
,
Packet
))
self
.
assertEqual
(
type
(
packet
),
Packets
.
Error
)
self
.
assertEqual
(
type
(
packet
),
Packets
.
Error
)
return
packet
return
packet
...
@@ -470,7 +466,7 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -470,7 +466,7 @@ class NeoUnitTestBase(NeoTestBase):
calls
=
conn
.
mockGetNamedCalls
(
'ask'
)
calls
=
conn
.
mockGetNamedCalls
(
'ask'
)
self
.
assertEqual
(
len
(
calls
),
1
)
self
.
assertEqual
(
len
(
calls
),
1
)
packet
=
calls
.
pop
().
getParam
(
0
)
packet
=
calls
.
pop
().
getParam
(
0
)
self
.
assertTrue
(
isinstance
(
packet
,
protocol
.
Packet
))
self
.
assertTrue
(
isinstance
(
packet
,
Packet
))
self
.
assertEqual
(
type
(
packet
),
packet_type
)
self
.
assertEqual
(
type
(
packet
),
packet_type
)
return
packet
return
packet
...
@@ -479,7 +475,7 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -479,7 +475,7 @@ class NeoUnitTestBase(NeoTestBase):
calls
=
conn
.
mockGetNamedCalls
(
'answer'
)
calls
=
conn
.
mockGetNamedCalls
(
'answer'
)
self
.
assertEqual
(
len
(
calls
),
1
)
self
.
assertEqual
(
len
(
calls
),
1
)
packet
=
calls
.
pop
().
getParam
(
0
)
packet
=
calls
.
pop
().
getParam
(
0
)
self
.
assertTrue
(
isinstance
(
packet
,
protocol
.
Packet
))
self
.
assertTrue
(
isinstance
(
packet
,
Packet
))
self
.
assertEqual
(
type
(
packet
),
packet_type
)
self
.
assertEqual
(
type
(
packet
),
packet_type
)
return
packet
return
packet
...
@@ -487,7 +483,7 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -487,7 +483,7 @@ class NeoUnitTestBase(NeoTestBase):
""" Check if a notify-packet with the right type is sent """
""" Check if a notify-packet with the right type is sent """
calls
=
conn
.
mockGetNamedCalls
(
'send'
)
calls
=
conn
.
mockGetNamedCalls
(
'send'
)
packet
=
calls
.
pop
(
packet_number
).
getParam
(
0
)
packet
=
calls
.
pop
(
packet_number
).
getParam
(
0
)
self
.
assertTrue
(
isinstance
(
packet
,
protocol
.
Packet
))
self
.
assertTrue
(
isinstance
(
packet
,
Packet
))
self
.
assertEqual
(
type
(
packet
),
packet_type
)
self
.
assertEqual
(
type
(
packet
),
packet_type
)
return
packet
return
packet
...
...
neo/tests/storage/testClientHandler.py
View file @
39ae4a2f
...
@@ -19,8 +19,9 @@ from ..mock import Mock, ReturnValues
...
@@ -19,8 +19,9 @@ from ..mock import Mock, ReturnValues
from
..
import
NeoUnitTestBase
from
..
import
NeoUnitTestBase
from
neo.storage.app
import
Application
from
neo.storage.app
import
Application
from
neo.storage.handlers.client
import
ClientOperationHandler
from
neo.storage.handlers.client
import
ClientOperationHandler
from
neo.lib.
util
import
p64
from
neo.lib.
exception
import
ProtocolError
from
neo.lib.protocol
import
INVALID_TID
,
Packets
from
neo.lib.protocol
import
INVALID_TID
,
Packets
from
neo.lib.util
import
p64
class
StorageClientHandlerTests
(
NeoUnitTestBase
):
class
StorageClientHandlerTests
(
NeoUnitTestBase
):
...
@@ -65,7 +66,8 @@ class StorageClientHandlerTests(NeoUnitTestBase):
...
@@ -65,7 +66,8 @@ class StorageClientHandlerTests(NeoUnitTestBase):
app
.
pt
=
Mock
()
app
.
pt
=
Mock
()
self
.
fakeDM
()
self
.
fakeDM
()
conn
=
self
.
_getConnection
()
conn
=
self
.
_getConnection
()
self
.
checkProtocolErrorRaised
(
self
.
operation
.
askTIDs
,
conn
,
1
,
1
,
None
)
self
.
assertRaises
(
ProtocolError
,
self
.
operation
.
askTIDs
,
conn
,
1
,
1
,
None
)
self
.
assertEqual
(
len
(
app
.
pt
.
mockGetNamedCalls
(
'getCellList'
)),
0
)
self
.
assertEqual
(
len
(
app
.
pt
.
mockGetNamedCalls
(
'getCellList'
)),
0
)
self
.
assertEqual
(
len
(
app
.
dm
.
mockGetNamedCalls
(
'getTIDList'
)),
0
)
self
.
assertEqual
(
len
(
app
.
dm
.
mockGetNamedCalls
(
'getTIDList'
)),
0
)
...
@@ -84,8 +86,8 @@ class StorageClientHandlerTests(NeoUnitTestBase):
...
@@ -84,8 +86,8 @@ class StorageClientHandlerTests(NeoUnitTestBase):
# invalid offsets => error
# invalid offsets => error
dm
=
self
.
fakeDM
()
dm
=
self
.
fakeDM
()
conn
=
self
.
_getConnection
()
conn
=
self
.
_getConnection
()
self
.
checkProtocolErrorRaised
(
self
.
operation
.
askObjectHistory
,
conn
,
self
.
assertRaises
(
ProtocolError
,
self
.
operation
.
askObjectHistory
,
1
,
1
,
None
)
conn
,
1
,
1
,
None
)
self
.
assertEqual
(
len
(
dm
.
mockGetNamedCalls
(
'getObjectHistory'
)),
0
)
self
.
assertEqual
(
len
(
dm
.
mockGetNamedCalls
(
'getObjectHistory'
)),
0
)
def
test_askObjectUndoSerial
(
self
):
def
test_askObjectUndoSerial
(
self
):
...
...
neo/tests/storage/testMasterHandler.py
View file @
39ae4a2f
...
@@ -19,8 +19,9 @@ from ..mock import Mock
...
@@ -19,8 +19,9 @@ from ..mock import Mock
from
..
import
NeoUnitTestBase
from
..
import
NeoUnitTestBase
from
neo.storage.app
import
Application
from
neo.storage.app
import
Application
from
neo.storage.handlers.master
import
MasterOperationHandler
from
neo.storage.handlers.master
import
MasterOperationHandler
from
neo.lib.exception
import
ProtocolError
from
neo.lib.protocol
import
CellStates
from
neo.lib.pt
import
PartitionTable
from
neo.lib.pt
import
PartitionTable
from
neo.lib.protocol
import
CellStates
,
ProtocolError
class
StorageMasterHandlerTests
(
NeoUnitTestBase
):
class
StorageMasterHandlerTests
(
NeoUnitTestBase
):
...
...
neo/tests/testHandler.py
View file @
39ae4a2f
...
@@ -17,9 +17,9 @@
...
@@ -17,9 +17,9 @@
import
unittest
import
unittest
from
.mock
import
Mock
from
.mock
import
Mock
from
.
import
NeoUnitTestBase
from
.
import
NeoUnitTestBase
from
neo.lib.handler
import
EventHandler
from
neo.lib.exception
import
PacketMalformedError
,
UnexpectedPacketError
,
\
from
neo.lib.protocol
import
PacketMalformedError
,
UnexpectedPacketError
,
\
NotReadyError
,
ProtocolError
NotReadyError
,
ProtocolError
from
neo.lib.handler
import
EventHandler
class
HandlerTests
(
NeoUnitTestBase
):
class
HandlerTests
(
NeoUnitTestBase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment