comparison src/test/helpers.py @ 941:c6d8fc63b1db

core, plugins: host.getClient now raise an exception instead of returning None when no profile is found, plugins have been adapted consequently and a bit cleaned
author Goffi <goffi@goffi.org>
date Fri, 28 Mar 2014 18:07:02 +0100
parents 64ec04991d9d
children e1842ebcb2f3
comparison
equal deleted inserted replaced
940:92e41e7c7e00 941:c6d8fc63b1db
15 # GNU Affero General Public License for more details. 15 # GNU Affero General Public License for more details.
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _
21 from sat.core import exceptions 20 from sat.core import exceptions
22 from constants import Const 21 from constants import Const
23 from wokkel.xmppim import RosterItem 22 from wokkel.xmppim import RosterItem
24 from sat.core.xmpp import SatRosterProtocol 23 from sat.core.xmpp import SatRosterProtocol
25 from sat.memory.memory import Params, Memory 24 from sat.memory.memory import Params, Memory
114 def getClient(self, profile_key): 113 def getClient(self, profile_key):
115 """Convenient method to get client from profile key 114 """Convenient method to get client from profile key
116 @return: client or None if it doesn't exist""" 115 @return: client or None if it doesn't exist"""
117 profile = self.memory.getProfileName(profile_key) 116 profile = self.memory.getProfileName(profile_key)
118 if not profile: 117 if not profile:
119 return None 118 raise exceptions.ProfileKeyUnknownError
120 if profile not in self.profiles: 119 if profile not in self.profiles:
121 self.profiles[profile] = FakeClient(self, profile) 120 self.profiles[profile] = FakeClient(self, profile)
122 self.profiles[profile].client_initialized.callback(None) 121 self.profiles[profile].client_initialized.callback(None)
123 return self.profiles[profile] 122 return self.profiles[profile]
124 123