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
980e464a
Commit
980e464a
authored
8 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
masz
parent
dcde5b3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
coolamqp/orders.py
+6
-7
6 additions, 7 deletions
coolamqp/orders.py
tests/test_basics.py
+7
-6
7 additions, 6 deletions
tests/test_basics.py
tests/test_failures.py
+24
-0
24 additions, 0 deletions
tests/test_failures.py
with
37 additions
and
13 deletions
coolamqp/orders.py
+
6
−
7
View file @
980e464a
...
...
@@ -106,17 +106,16 @@ class CancelQueue(Order):
self
.
queue
=
queue
class
AcknowledgeMessage
(
Order
):
"""
ACK a message
"""
class
_AcksAndNacks
(
Order
):
"""
related to acking and nacking
"""
def
__init__
(
self
,
connect_id
,
delivery_tag
,
on_completed
):
Order
.
__init__
(
self
,
on_completed
=
on_completed
)
self
.
connect_id
=
connect_id
self
.
delivery_tag
=
delivery_tag
class
AcknowledgeMessage
(
_AcksAndNacks
):
"""
ACK a message
"""
class
NAcknowledgeMessage
(
Order
):
class
NAcknowledgeMessage
(
_AcksAndNacks
):
"""
NACK a message
"""
def
__init__
(
self
,
connect_id
,
delivery_tag
,
on_completed
):
Order
.
__init__
(
self
,
on_completed
=
on_completed
)
self
.
connect_id
=
connect_id
self
.
delivery_tag
=
delivery_tag
This diff is collapsed.
Click to expand it.
tests/test_basics.py
+
7
−
6
View file @
980e464a
#coding=UTF-8
from
__future__
import
absolute_import
,
division
,
print_function
import
unittest
import
six
from
coolamqp
import
Cluster
,
ClusterNode
,
Queue
,
MessageReceived
,
ConnectionUp
,
\
ConnectionDown
,
ConsumerCancelled
,
Message
...
...
@@ -19,7 +20,7 @@ class TestBasics(unittest.TestCase):
myq
=
Queue
(
'
myqueue
'
,
exclusive
=
True
)
self
.
amqp
.
consume
(
myq
)
self
.
amqp
.
send
(
Message
(
b
'
what the fuck
'
),
''
,
routing_key
=
'
myqueue
'
)
self
.
amqp
.
send
(
Message
(
'
what the fuck
'
),
''
,
routing_key
=
'
myqueue
'
)
p
=
self
.
amqp
.
drain
(
wait
=
4
)
self
.
assertIsInstance
(
p
,
MessageReceived
)
...
...
@@ -34,16 +35,16 @@ class TestBasics(unittest.TestCase):
myq
=
Queue
(
'
myqueue
'
,
exclusive
=
True
)
self
.
amqp
.
consume
(
myq
)
self
.
amqp
.
send
(
Message
(
b
'
what the fuck
'
),
''
,
routing_key
=
'
myqueue
'
)
self
.
amqp
.
send
(
Message
(
'
what the fuck
'
),
''
,
routing_key
=
'
myqueue
'
)
p
=
self
.
amqp
.
drain
(
wait
=
4
)
self
.
assertIsInstance
(
p
,
MessageReceived
)
self
.
assertEquals
(
p
.
message
.
body
,
b
'
what the fuck
'
)
self
.
assertEquals
(
p
.
message
.
body
,
'
what the fuck
'
)
p
.
message
.
nack
()
p
=
self
.
amqp
.
drain
(
wait
=
4
)
self
.
assertIsInstance
(
p
,
MessageReceived
)
self
.
assertEquals
(
p
.
message
.
body
,
b
'
what the fuck
'
)
self
.
assertEquals
(
six
.
binary_type
(
p
.
message
.
body
)
,
'
what the fuck
'
)
self
.
amqp
.
delete_queue
(
myq
)
...
...
@@ -51,11 +52,11 @@ class TestBasics(unittest.TestCase):
myq
=
Queue
(
'
myqueue
'
,
exclusive
=
True
)
self
.
amqp
.
consume
(
myq
)
self
.
amqp
.
send
(
Message
(
b
'
what the fuck
'
),
''
,
routing_key
=
'
myqueue
'
)
self
.
amqp
.
send
(
Message
(
'
what the fuck
'
),
''
,
routing_key
=
'
myqueue
'
)
p
=
self
.
amqp
.
drain
(
wait
=
10
)
self
.
assertIsInstance
(
p
,
MessageReceived
)
self
.
assertEquals
(
p
.
message
.
body
,
b
'
what the fuck
'
)
self
.
assertEquals
(
p
.
message
.
body
,
'
what the fuck
'
)
def
test_consumer_cancelled_on_queue_deletion
(
self
):
myq
=
Queue
(
'
myqueue
'
,
exclusive
=
True
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_failures.py
0 → 100644
+
24
−
0
View file @
980e464a
#coding=UTF-8
from
__future__
import
absolute_import
,
division
,
print_function
import
unittest
import
os
from
coolamqp
import
Cluster
,
ClusterNode
,
Queue
,
MessageReceived
,
ConnectionUp
,
\
ConnectionDown
,
ConsumerCancelled
,
Message
class
TestFailures
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
amqp
=
Cluster
([
ClusterNode
(
'
127.0.0.1
'
,
'
guest
'
,
'
guest
'
)])
self
.
amqp
.
start
()
self
.
assertIsInstance
(
self
.
amqp
.
drain
(
1
),
ConnectionUp
)
def
tearDown
(
self
):
self
.
amqp
.
shutdown
()
def
test_connection_down_and_up
(
self
):
"""
are messages generated at all? does it reconnect?
"""
os
.
system
(
"
sudo service rabbitmq-server restart
"
)
self
.
assertIsInstance
(
self
.
amqp
.
drain
(
wait
=
4
),
ConnectionDown
)
self
.
assertIsInstance
(
self
.
amqp
.
drain
(
wait
=
6
),
ConnectionUp
)
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