Remove superfluous clear_contacts method
This commit is contained in:
parent
004619f99e
commit
ba9ef8301b
|
@ -298,9 +298,6 @@ class Contacts:
|
||||||
if len(self._contacts[account][contact.jid]) == 0:
|
if len(self._contacts[account][contact.jid]) == 0:
|
||||||
del self._contacts[account][contact.jid]
|
del self._contacts[account][contact.jid]
|
||||||
|
|
||||||
def clear_contacts(self, account):
|
|
||||||
self._contacts[account] = {}
|
|
||||||
|
|
||||||
def remove_jid(self, account, jid, remove_meta=True):
|
def remove_jid(self, account, jid, remove_meta=True):
|
||||||
'''Removes all contacts for a given jid'''
|
'''Removes all contacts for a given jid'''
|
||||||
if account not in self._contacts:
|
if account not in self._contacts:
|
||||||
|
|
|
@ -7,6 +7,7 @@ import lib
|
||||||
lib.setup_env()
|
lib.setup_env()
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import contacts as contacts_module
|
||||||
from gajim import Interface
|
from gajim import Interface
|
||||||
|
|
||||||
from gajim_mocks import *
|
from gajim_mocks import *
|
||||||
|
@ -25,6 +26,9 @@ class TestStatusChange(unittest.TestCase):
|
||||||
'''tests gajim.py's incredibly complex handle_event_notify'''
|
'''tests gajim.py's incredibly complex handle_event_notify'''
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
||||||
|
gajim.connections = {}
|
||||||
|
gajim.contacts = contacts_module.Contacts()
|
||||||
gajim.interface.roster = roster_window.RosterWindow()
|
gajim.interface.roster = roster_window.RosterWindow()
|
||||||
|
|
||||||
for acc in contacts:
|
for acc in contacts:
|
||||||
|
@ -38,13 +42,6 @@ class TestStatusChange(unittest.TestCase):
|
||||||
self.assertEqual(0, len(notify.notifications))
|
self.assertEqual(0, len(notify.notifications))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
gajim.interface.roster.model.clear()
|
|
||||||
|
|
||||||
for acc in contacts:
|
|
||||||
gajim.contacts.clear_contacts(acc)
|
|
||||||
|
|
||||||
del gajim.interface.roster
|
|
||||||
|
|
||||||
notify.notifications = []
|
notify.notifications = []
|
||||||
|
|
||||||
def contact_comes_online(self, account, jid, resource, prio):
|
def contact_comes_online(self, account, jid, resource, prio):
|
||||||
|
|
|
@ -9,15 +9,16 @@ from mock import Mock, expectParams
|
||||||
from gajim_mocks import *
|
from gajim_mocks import *
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import contacts as contacts_module
|
||||||
import roster_window
|
import roster_window
|
||||||
|
|
||||||
gajim.get_jid_from_account = lambda acc: 'myjid@' + acc
|
gajim.get_jid_from_account = lambda acc: 'myjid@' + acc
|
||||||
|
|
||||||
|
|
||||||
class TestRosterWindow(unittest.TestCase):
|
class TestRosterWindow(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
gajim.interface = MockInterface()
|
gajim.interface = MockInterface()
|
||||||
self.roster = roster_window.RosterWindow()
|
|
||||||
|
|
||||||
self.C_NAME = roster_window.C_NAME
|
self.C_NAME = roster_window.C_NAME
|
||||||
self.C_TYPE = roster_window.C_TYPE
|
self.C_TYPE = roster_window.C_TYPE
|
||||||
|
@ -26,13 +27,13 @@ class TestRosterWindow(unittest.TestCase):
|
||||||
|
|
||||||
# Add after creating RosterWindow
|
# Add after creating RosterWindow
|
||||||
# We want to test the filling explicitly
|
# We want to test the filling explicitly
|
||||||
|
gajim.contacts = contacts_module.Contacts()
|
||||||
|
gajim.connections = {}
|
||||||
|
self.roster = roster_window.RosterWindow()
|
||||||
|
|
||||||
for acc in contacts:
|
for acc in contacts:
|
||||||
gajim.connections[acc] = MockConnection(acc)
|
gajim.connections[acc] = MockConnection(acc)
|
||||||
|
gajim.contacts.add_account(acc)
|
||||||
def tearDown(self):
|
|
||||||
self.roster.model.clear()
|
|
||||||
for acc in gajim.contacts.get_accounts():
|
|
||||||
gajim.contacts.clear_contacts(acc)
|
|
||||||
|
|
||||||
### Custom assertions
|
### Custom assertions
|
||||||
def assert_all_contacts_are_in_roster(self, acc):
|
def assert_all_contacts_are_in_roster(self, acc):
|
||||||
|
@ -142,11 +143,6 @@ class TestRosterWindow(unittest.TestCase):
|
||||||
|
|
||||||
groups = contacts[acc][jid]['groups'] or ['General',]
|
groups = contacts[acc][jid]['groups'] or ['General',]
|
||||||
|
|
||||||
# cleanup
|
|
||||||
self.roster.model.clear()
|
|
||||||
for acc in contacts:
|
|
||||||
gajim.contacts.clear_contacts(acc)
|
|
||||||
|
|
||||||
def test_fill_roster_model(self):
|
def test_fill_roster_model(self):
|
||||||
for acc in contacts:
|
for acc in contacts:
|
||||||
self.roster.fill_contacts_and_groups_dicts(contacts[acc], acc)
|
self.roster.fill_contacts_and_groups_dicts(contacts[acc], acc)
|
||||||
|
|
Loading…
Reference in New Issue