1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
from collections.abc import Mapping, MutableMapping
from unittest.mock import Mock
from celery.app.utils import Settings, bugreport, filter_hidden_settings
class test_Settings:
def test_is_mapping(self):
"""Settings should be a collections.Mapping"""
assert issubclass(Settings, Mapping)
def test_is_mutable_mapping(self):
"""Settings should be a collections.MutableMapping"""
assert issubclass(Settings, MutableMapping)
def test_find(self):
assert self.app.conf.find_option('always_eager')
def test_get_by_parts(self):
self.app.conf.task_do_this_and_that = 303
assert self.app.conf.get_by_parts(
'task', 'do', 'this', 'and', 'that') == 303
def test_find_value_for_key(self):
assert self.app.conf.find_value_for_key(
'always_eager') is False
def test_table(self):
assert self.app.conf.table(with_defaults=True)
assert self.app.conf.table(with_defaults=False)
assert self.app.conf.table(censored=False)
assert self.app.conf.table(censored=True)
class test_filter_hidden_settings:
def test_handles_non_string_keys(self):
"""filter_hidden_settings shouldn't raise an exception when handling
mappings with non-string keys"""
conf = {
'STRING_KEY': 'VALUE1',
('NON', 'STRING', 'KEY'): 'VALUE2',
'STRING_KEY2': {
'STRING_KEY3': 1,
('NON', 'STRING', 'KEY', '2'): 2
},
}
filter_hidden_settings(conf)
class test_bugreport:
def test_no_conn_driver_info(self):
self.app.connection = Mock()
conn = self.app.connection.return_value = Mock()
conn.transport = None
bugreport(self.app)
|