Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coolamqp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
coolamqp
Commits
9ff28737
Commit
9ff28737
authored
8 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
moar tests
parent
cf473286
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
coolamqp/attaches/consumer.py
+4
-0
4 additions, 0 deletions
coolamqp/attaches/consumer.py
coolamqp/clustering/cluster.py
+6
-2
6 additions, 2 deletions
coolamqp/clustering/cluster.py
tests/test_clustering/test_a.py
+26
-10
26 additions, 10 deletions
tests/test_clustering/test_a.py
with
36 additions
and
12 deletions
coolamqp/attaches/consumer.py
+
4
−
0
View file @
9ff28737
...
@@ -367,6 +367,10 @@ class MessageReceiver(object):
...
@@ -367,6 +367,10 @@ class MessageReceiver(object):
self
.
data_to_go
=
frame
.
body_size
self
.
data_to_go
=
frame
.
body_size
self
.
state
=
2
self
.
state
=
2
if
self
.
header
.
body_size
==
0
:
# An empty message is no common guest. It won't have a BODY field though...
self
.
on_body
(
b
''
)
# trigger it manually
def
on_basic_deliver
(
self
,
payload
):
def
on_basic_deliver
(
self
,
payload
):
assert
self
.
state
==
0
assert
self
.
state
==
0
self
.
bdeliver
=
payload
self
.
bdeliver
=
payload
...
...
This diff is collapsed.
Click to expand it.
coolamqp/clustering/cluster.py
+
6
−
2
View file @
9ff28737
...
@@ -97,10 +97,14 @@ class Cluster(object):
...
@@ -97,10 +97,14 @@ class Cluster(object):
:return: Future or None
:return: Future or None
"""
"""
if
isinstance
(
exchange
,
Exchange
):
if
isinstance
(
exchange
,
Exchange
):
exchange
=
exchange
.
name
exchange
=
exchange
.
name
.
encode
(
'
utf8
'
)
elif
exchange
is
None
:
exchange
=
b
''
else
:
exchange
=
exchange
.
encode
(
'
utf8
'
)
try
:
try
:
return
(
self
.
pub_tr
if
tx
else
self
.
pub_na
).
publish
(
message
,
exchange
.
encode
(
'
utf8
'
)
,
routing_key
.
encode
(
'
utf8
'
))
return
(
self
.
pub_tr
if
tx
else
self
.
pub_na
).
publish
(
message
,
exchange
,
routing_key
.
encode
(
'
utf8
'
))
except
Publisher
.
UnusablePublisher
:
except
Publisher
.
UnusablePublisher
:
raise
NotImplementedError
(
u
'
Sorry, this functionality is not yet implemented!
'
)
raise
NotImplementedError
(
u
'
Sorry, this functionality is not yet implemented!
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_clustering/test_a.py
+
26
−
10
View file @
9ff28737
...
@@ -6,7 +6,7 @@ from __future__ import print_function, absolute_import, division
...
@@ -6,7 +6,7 @@ from __future__ import print_function, absolute_import, division
import
six
import
six
import
unittest
import
unittest
import
time
,
logging
,
threading
import
time
,
logging
,
threading
from
coolamqp.objects
import
Message
,
MessageProperties
,
NodeDefinition
,
Queue
from
coolamqp.objects
import
Message
,
MessageProperties
,
NodeDefinition
,
Queue
,
ReceivedMessage
from
coolamqp.clustering
import
Cluster
from
coolamqp.clustering
import
Cluster
import
time
import
time
...
@@ -17,18 +17,34 @@ logging.basicConfig(level=logging.DEBUG)
...
@@ -17,18 +17,34 @@ logging.basicConfig(level=logging.DEBUG)
class
TestA
(
unittest
.
TestCase
):
class
TestA
(
unittest
.
TestCase
):
def
test_link
(
self
):
"""
Connect and disconnect
"""
def
setUp
(
self
):
c
=
Cluster
([
NODE
])
self
.
c
=
Cluster
([
NODE
])
c
.
start
()
self
.
c
.
start
()
c
.
shutdown
()
def
tearDown
(
self
):
self
.
c
.
shutdown
()
def
test_consume
(
self
):
def
test_consume
(
self
):
c
=
Cluster
([
NODE
])
con
,
fut
=
self
.
c
.
consume
(
Queue
(
u
'
hello
'
,
exclusive
=
True
))
c
.
start
()
con
,
fut
=
c
.
consume
(
Queue
(
u
'
hello
'
,
exclusive
=
True
))
# fut.result()
# fut.result()
con
.
cancel
()
con
.
cancel
()
c
.
shutdown
()
def
test_send_recv
(
self
):
P
=
{
'
q
'
:
False
}
def
ok
(
e
):
self
.
assertIsInstance
(
e
,
ReceivedMessage
)
P
[
'
q
'
]
=
True
con
,
fut
=
self
.
c
.
consume
(
Queue
(
u
'
hello
'
,
exclusive
=
True
),
on_message
=
ok
,
no_ack
=
True
)
fut
.
result
()
self
.
c
.
publish
(
Message
(
b
''
),
routing_key
=
u
'
hello
'
,
tx
=
True
).
result
()
time
.
sleep
(
1
)
self
.
assertTrue
(
P
[
'
q
'
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment