1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
5 Tests for L{twisted.words.im.basechat}.
8 from twisted.trial import unittest
9 from twisted.words.im import basechat, basesupport
12 class ChatUITests(unittest.TestCase):
14 Tests for the L{basechat.ChatUI} chat client.
17 self.ui = basechat.ChatUI()
18 self.account = basesupport.AbstractAccount("fooAccount", False, "foo",
19 "password", "host", "port")
20 self.person = basesupport.AbstractPerson("foo", self.account)
23 def test_contactChangedNickNoKey(self):
25 L{basechat.ChatUI.contactChangedNick} on an
26 L{twisted.words.im.interfaces.IPerson} who doesn't have an account
27 associated with the L{basechat.ChatUI} instance has no effect.
29 self.assertEqual(self.person.name, "foo")
30 self.assertEqual(self.person.account, self.account)
32 self.ui.contactChangedNick(self.person, "bar")
33 self.assertEqual(self.person.name, "foo")
34 self.assertEqual(self.person.account, self.account)
37 def test_contactChangedNickNoConversation(self):
39 L{basechat.ChatUI.contactChangedNick} changes the name for an
40 L{twisted.words.im.interfaces.IPerson}.
42 self.ui.persons[self.person.name, self.person.account] = self.person
44 self.assertEqual(self.person.name, "foo")
45 self.assertEqual(self.person.account, self.account)
47 self.ui.contactChangedNick(self.person, "bar")
48 self.assertEqual(self.person.name, "bar")
49 self.assertEqual(self.person.account, self.account)
52 def test_contactChangedNickHasConversation(self):
54 If an L{twisted.words.im.interfaces.IPerson} is in a
55 L{basechat.Conversation}, L{basechat.ChatUI.contactChangedNick} causes a
56 name change for that person in both the L{basechat.Conversation} and the
59 self.ui.persons[self.person.name, self.person.account] = self.person
60 conversation = basechat.Conversation(self.person, self.ui)
61 self.ui.conversations[self.person] = conversation
63 self.assertEqual(self.person.name, "foo")
64 self.assertEqual(self.person.account, self.account)
66 self.ui.contactChangedNick(self.person, "bar")
67 self.assertEqual(self.person.name, "bar")
68 self.assertEqual(self.person.account, self.account)