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
47e777ee
Commit
47e777ee
authored
7 months ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
fixes
#3
parent
3abdfb2b
No related branches found
No related tags found
No related merge requests found
Pipeline
#63420
failed with stages
Stage: unittest
Stage: build
in 2 minutes and 2 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+7
-7
7 additions, 7 deletions
.gitlab-ci.yml
coolamqp/objects.py
+10
-6
10 additions, 6 deletions
coolamqp/objects.py
tests/test_clustering/test_exchanges.py
+1
-0
1 addition, 0 deletions
tests/test_clustering/test_exchanges.py
tests/test_objects.py
+7
-2
7 additions, 2 deletions
tests/test_objects.py
with
25 additions
and
15 deletions
.gitlab-ci.yml
+
7
−
7
View file @
47e777ee
...
@@ -60,18 +60,18 @@ unittest_select:
...
@@ -60,18 +60,18 @@ unittest_select:
unittest_epoll_python27
:
unittest_epoll_python27
:
extends
:
.before_
test
stage
:
unit
test
image
:
python:2.7
image
:
python:2.7
variables
:
AMQP_HOST
:
"
rabbitmq"
before_script
:
before_script
:
-
pip install nose2 nose2[coverage_plugin]
-
pip install nose2
coverage requests yapf
nose2[coverage_plugin]
-
python setup.py install
-
python setup.py install
script
:
script
:
-
nose2 -F -vv
-
nose2 -F -vv
variables
:
services
:
AMQP_HOST
:
"
rabbitmq"
-
name
:
rabbitmq:3.10-management
after_script
:
alias
:
rabbitmq
-
mv .coverage .coverage.python27epoll
unittest_epoll
:
unittest_epoll
:
extends
:
.before_test
extends
:
.before_test
...
...
This diff is collapsed.
Click to expand it.
coolamqp/objects.py
+
10
−
6
View file @
47e777ee
...
@@ -27,6 +27,8 @@ def toutf8(q):
...
@@ -27,6 +27,8 @@ def toutf8(q):
def
tobytes
(
q
):
def
tobytes
(
q
):
if
isinstance
(
q
,
memoryview
):
return
q
.
tobytes
()
return
q
.
encode
(
'
utf-8
'
)
if
isinstance
(
q
,
six
.
text_type
)
else
q
return
q
.
encode
(
'
utf-8
'
)
if
isinstance
(
q
,
six
.
text_type
)
else
q
...
@@ -287,8 +289,7 @@ class Queue(object):
...
@@ -287,8 +289,7 @@ class Queue(object):
if
name
is
None
:
if
name
is
None
:
self
.
name
=
None
self
.
name
=
None
else
:
else
:
name
=
uuid
.
uuid4
().
hex
if
not
name
else
name
self
.
name
=
tobytes
(
uuid
.
uuid4
().
hex
if
not
name
else
name
)
self
.
name
=
tobytes
(
name
)
self
.
durable
=
durable
self
.
durable
=
durable
self
.
exchange
=
exchange
self
.
exchange
=
exchange
...
@@ -303,10 +304,10 @@ class Queue(object):
...
@@ -303,10 +304,10 @@ class Queue(object):
if
self
.
anonymous
and
(
not
self
.
auto_delete
or
self
.
durable
):
if
self
.
anonymous
and
(
not
self
.
auto_delete
or
self
.
durable
):
raise
ValueError
(
'
Zero sense to make a anonymous non-auto-delete or durable queue
'
)
raise
ValueError
(
'
Zero sense to make a anonymous non-auto-delete or durable queue
'
)
if
not
self
.
anonymous
:
if
not
self
.
anonymous
and
(
self
.
auto_delete
or
self
.
exclusive
)
:
if
self
.
auto_delete
or
self
.
exclusive
:
warnings
.
warn
(
'
This may cause unpredictable behaviour
'
,
UserWarning
)
warnings
.
warn
(
'
This may cause unpredictable behaviour
'
,
UserWarning
)
el
if
self
.
durable
:
if
self
.
durable
and
self
.
anonymous
:
raise
ValueError
(
'
Cannot declare an anonymous durable queue
'
)
raise
ValueError
(
'
Cannot declare an anonymous durable queue
'
)
if
self
.
auto_delete
and
not
self
.
exclusive
and
not
self
.
anonymous
:
if
self
.
auto_delete
and
not
self
.
exclusive
and
not
self
.
anonymous
:
...
@@ -323,6 +324,9 @@ class Queue(object):
...
@@ -323,6 +324,9 @@ class Queue(object):
def
__hash__
(
self
):
def
__hash__
(
self
):
return
hash
(
self
.
name
)
return
hash
(
self
.
name
)
def
__repr__
(
self
):
return
'
Queue(%s, %s, %s, %s, %s, %s
'
%
(
self
.
name
,
self
.
durable
,
self
.
exchange
,
self
.
exclusive
,
self
.
arguments
)
class
QueueBind
(
object
):
class
QueueBind
(
object
):
"""
An order to be declared which binds a given queue to an exchange
"""
"""
An order to be declared which binds a given queue to an exchange
"""
...
...
This diff is collapsed.
Click to expand it.
tests/test_clustering/test_exchanges.py
+
1
−
0
View file @
47e777ee
...
@@ -13,6 +13,7 @@ from coolamqp.objects import Message, NodeDefinition, Queue, MessageProperties,
...
@@ -13,6 +13,7 @@ from coolamqp.objects import Message, NodeDefinition, Queue, MessageProperties,
NODE
=
NodeDefinition
(
os
.
environ
.
get
(
'
AMQP_HOST
'
,
'
127.0.0.1
'
),
'
guest
'
,
'
guest
'
,
heartbeat
=
20
)
NODE
=
NodeDefinition
(
os
.
environ
.
get
(
'
AMQP_HOST
'
,
'
127.0.0.1
'
),
'
guest
'
,
'
guest
'
,
heartbeat
=
20
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logging
.
getLogger
(
'
coolamqp
'
).
setLevel
(
logging
.
DEBUG
)
logging
.
getLogger
(
'
coolamqp
'
).
setLevel
(
logging
.
DEBUG
)
logger
=
logging
.
getLogger
(
__name__
)
class
TestExchanges
(
unittest
.
TestCase
):
class
TestExchanges
(
unittest
.
TestCase
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_objects.py
+
7
−
2
View file @
47e777ee
# coding=UTF-8
# coding=UTF-8
from
__future__
import
print_function
,
absolute_import
,
division
from
__future__
import
print_function
,
absolute_import
,
division
import
sys
import
logging
import
logging
import
unittest
import
unittest
import
io
import
io
...
@@ -13,6 +14,8 @@ from coolamqp.objects import NodeDefinition, MessageProperties, Queue, argumenti
...
@@ -13,6 +14,8 @@ from coolamqp.objects import NodeDefinition, MessageProperties, Queue, argumenti
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
logging
.
getLogger
(
'
coolamqp
'
).
setLevel
(
logging
.
DEBUG
)
logging
.
getLogger
(
'
coolamqp
'
).
setLevel
(
logging
.
DEBUG
)
IS_PY3
=
sys
.
version
.
startswith
(
'
3
'
)
class
TestObjects
(
unittest
.
TestCase
):
class
TestObjects
(
unittest
.
TestCase
):
...
@@ -26,9 +29,11 @@ class TestObjects(unittest.TestCase):
...
@@ -26,9 +29,11 @@ class TestObjects(unittest.TestCase):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
Queue
(
'
test
'
,
auto_delete
=
True
,
exclusive
=
True
)
Queue
(
'
test
'
,
auto_delete
=
True
,
exclusive
=
True
)
Queue
(
auto_delete
=
True
,
exclusive
=
False
)
Queue
(
auto_delete
=
True
,
exclusive
=
False
)
self
.
assertEqual
(
len
(
w
),
2
)
logger
.
warning
(
repr
(
w
))
self
.
assertEqual
(
len
(
w
),
2
if
IS_PY3
else
1
)
self
.
assertTrue
(
issubclass
(
w
[
0
].
category
,
UserWarning
))
self
.
assertTrue
(
issubclass
(
w
[
0
].
category
,
UserWarning
))
self
.
assertTrue
(
issubclass
(
w
[
1
].
category
,
DeprecationWarning
))
if
IS_PY3
:
self
.
assertTrue
(
issubclass
(
w
[
1
].
category
,
DeprecationWarning
))
def
test_queue_declare
(
self
):
def
test_queue_declare
(
self
):
args
=
argumentify
({
'
x-dead-letter-exchange
'
:
'
deadletter
'
,
args
=
argumentify
({
'
x-dead-letter-exchange
'
:
'
deadletter
'
,
...
...
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