示例#1
0
 def test_name_change(self):
     c = Client(console=b3.console, authed=True)
     c.name = "cucurb"
     self.assertEqual(c.name, "cucurb")
     b3.console.queueEvent.assert_called()
     args = b3.console.queueEvent.call_args
     eventraised = args[0][0]
     self.assertEquals(eventraised.type, b3.events.EVT_CLIENT_NAME_CHANGE)
     self.assertEquals(eventraised.data, 'cucurb')
示例#2
0
 def test_makeAlias_new(self):
     c = Client(console=b3.console)
     c.id = 123
     c.name = "foo"
     b3.console.storage.getClientAlias.side_effect = KeyError()
     c.makeAlias("bar")
     self.assertEquals(b3.console.storage.getClientAlias.call_count, 1)
     alias = b3.console.storage.getClientAlias.call_args[0][0]
     self.assertIsInstance(alias, b3.clients.Alias)
     self.assertEqual(alias.alias, "bar")
     self.assertEqual(alias.numUsed, 1)
示例#3
0
 def test_makeAlias_existing(self):
     c = Client(console=b3.console)
     c.id = 123
     c.name = "foo"
     aliasFoo = b3.clients.Alias()
     aliasFoo.alias = "foo"
     aliasFoo.clientId = c.id
     aliasFoo.numUsed = 48
     b3.console.storage.getClientAlias.side_effect = lambda x: aliasFoo
     c.makeAlias("whatever")
     self.assertEquals(b3.console.storage.getClientAlias.call_count, 1)
     self.assertIsInstance(aliasFoo, b3.clients.Alias)
     self.assertEqual(aliasFoo.alias, "foo")
     self.assertEqual(aliasFoo.numUsed, 49)