def setUp(self): self.roster = jclib.instrumentable_list.ModelList() self.roster.extend( unittest.mock.Mock(spec=jclib.roster.AbstractRosterItem) for i in range(3)) self.roster[0].tags = ["foo", "bar"] self.roster[1].tags = ["bar"] self.roster[2].tags = ["foo", "baz"] self.avatar = unittest.mock.Mock(spec=jabbercat.avatar.AvatarManager) self.rm = models.RosterModel(self.roster, self.avatar) self.rfm = models.RosterFilterModel() self.rfm.setSourceModel(self.rm) self.tags = jclib.instrumentable_list.ModelList([ "foo", "bar", "baz", ]) self.tags_model = models.TagsModel(self.tags) self.tags_check_model = models.CheckModel() self.tags_check_model.setSourceModel(self.tags_model) self.rfm.tags_filter_model = self.tags_check_model self.listener = make_listener(self.rfm)
def test_uses_model_list_adaptor(self): tags = unittest.mock.Mock() with contextlib.ExitStack() as stack: ModelListAdaptor = stack.enter_context( unittest.mock.patch( "jabbercat.model_adaptor.ModelListAdaptor")) result = models.TagsModel(tags) ModelListAdaptor.assert_called_once_with(tags, result)
def setUp(self): self.tags = jclib.instrumentable_list.ModelList([ "foo", "bar", ]) self.tm = models.TagsModel(self.tags) self.m = models.CheckModel() self.m.setSourceModel(self.tm) self.listener = unittest.mock.Mock([]) self.listener.dataChanged = unittest.mock.Mock() self.listener.dataChanged.return_value = None self.m.dataChanged.connect(self.listener.dataChanged)
def setUp(self): self.tags = jclib.instrumentable_list.ModelList([ "foo", "bar", ]) self.m = models.TagsModel(self.tags)