comparison tests/unit/conftest.py @ 4037:524856bd7b19

massive refactoring to switch from camelCase to snake_case: historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents 9496f28dadff
children 4b842c1fb686
comparison
equal deleted inserted replaced
4036:c4464d7ae97b 4037:524856bd7b19
27 27
28 28
29 @fixture(scope="session") 29 @fixture(scope="session")
30 def bridge(): 30 def bridge():
31 bridge = AsyncMock() 31 bridge = AsyncMock()
32 bridge.addSignal = MagicMock() 32 bridge.add_signal = MagicMock()
33 bridge.addMethod = MagicMock() 33 bridge.add_method = MagicMock()
34 return bridge 34 return bridge
35 35
36 36
37 @fixture(scope="session") 37 @fixture(scope="session")
38 def storage(): 38 def storage():
47 self._menus_paths = {} 47 self._menus_paths = {}
48 self._test_config = {} 48 self._test_config = {}
49 self.profiles = {} 49 self.profiles = {}
50 self.plugins = {} 50 self.plugins = {}
51 # map for short name to whole namespace, 51 # map for short name to whole namespace,
52 # extended by plugins with registerNamespace 52 # extended by plugins with register_namespace
53 self.ns_map = { 53 self.ns_map = {
54 "x-data": xmpp.NS_X_DATA, 54 "x-data": xmpp.NS_X_DATA,
55 "disco#info": xmpp.NS_DISCO_INFO, 55 "disco#info": xmpp.NS_DISCO_INFO,
56 } 56 }
57 self.memory = MagicMock() 57 self.memory = MagicMock()
58 self.memory.storage = storage 58 self.memory.storage = storage
59 self.memory.getConfig.side_effect = self.get_test_config 59 self.memory.config_get.side_effect = self.get_test_config
60 60
61 self.trigger = trigger.TriggerManager() 61 self.trigger = trigger.TriggerManager()
62 self.bridge = bridge 62 self.bridge = bridge
63 defer.ensureDeferred(self._post_init()) 63 defer.ensureDeferred(self._post_init())
64 self.common_cache = AsyncMock() 64 self.common_cache = AsyncMock()
65 self._import_plugins() 65 self._import_plugins()
66 self._addBaseMenus() 66 self._add_base_menus()
67 self.initialised = defer.Deferred() 67 self.initialised = defer.Deferred()
68 self.initialised.callback(None) 68 self.initialised.callback(None)
69 69
70 def get_test_config(self, section, name, default=None): 70 def get_test_config(self, section, name, default=None):
71 return self._test_config.get((section or None, name), default) 71 return self._test_config.get((section or None, name), default)