mirror of https://github.com/celery/kombu.git
enable/fix test_etcd.py
This commit is contained in:
parent
e8175a1668
commit
aec8faf034
|
@ -15,3 +15,4 @@ urllib3>=1.26.16; sys_platform != 'win32'
|
|||
-r extras/brotli.txt
|
||||
-r extras/zstd.txt
|
||||
-r extras/sqlalchemy.txt
|
||||
-r extras/etcd.txt
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from array import array
|
||||
from queue import Empty
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
|
@ -14,9 +15,11 @@ class test_Etcd:
|
|||
|
||||
def setup_method(self):
|
||||
self.connection = Mock()
|
||||
self.connection._used_channel_ids = array('H')
|
||||
self.connection.channel_max = 65535
|
||||
self.connection.client.transport_options = {}
|
||||
self.connection.client.port = 2739
|
||||
self.client = self.patch('etcd.Client').return_value
|
||||
self.client = self.patching('etcd.Client').return_value
|
||||
self.channel = Channel(connection=self.connection)
|
||||
|
||||
def test_driver_version(self):
|
||||
|
@ -42,26 +45,26 @@ class test_Etcd:
|
|||
queue = 'mynewqueue'
|
||||
|
||||
with patch('etcd.Lock'):
|
||||
self.client.write.return_value = self.patch('etcd.EtcdResult')
|
||||
self.client.write.return_value = self.patching('etcd.EtcdResult')
|
||||
assert self.channel._new_queue(queue)
|
||||
|
||||
self.client.delete.return_value = self.patch('etcd.EtcdResult')
|
||||
self.client.delete.return_value = self.patching('etcd.EtcdResult')
|
||||
self.channel._delete(queue)
|
||||
|
||||
def test_size(self):
|
||||
with patch('etcd.Lock'):
|
||||
self.client.read.return_value = self.patch(
|
||||
self.client.read.return_value = self.patching(
|
||||
'etcd.EtcdResult', _children=[{}, {}])
|
||||
assert self.channel._size('q') == 2
|
||||
|
||||
def test_get(self):
|
||||
with patch('etcd.Lock'):
|
||||
self.client.read.return_value = self.patch(
|
||||
self.client.read.return_value = self.patching(
|
||||
'etcd.EtcdResult',
|
||||
_children=[{'key': 'myqueue', 'modifyIndex': 1, 'value': '1'}])
|
||||
assert self.channel._get('myqueue') is not None
|
||||
|
||||
def test_put(self):
|
||||
with patch('etcd.Lock'):
|
||||
self.client.write.return_value = self.patch('etcd.EtcdResult')
|
||||
self.client.write.return_value = self.patching('etcd.EtcdResult')
|
||||
assert self.channel._put('myqueue', 'mydata') is None
|
||||
|
|
Loading…
Reference in New Issue