def testNamedEvents(self): data = NamedEvents() temp = 'hello world' events.register(temp) called_list = [] def test_listener_one(x): called_list.append(x) def test_listener_two(x): called_list.remove(x) data.add_item += test_listener_one data.remove_item += test_listener_two data.getEvent('fake') data.add_item(True) self.assertTrue(True in called_list) data.remove_item(True) self.assertTrue(True not in called_list)
def testMessageView(self): WidgetMessage = messages.model_message(Widget) controller = Bunch(events=NamedEvents(), response=Bunch()) view = MessageView(controller) view.context['data'] = WidgetMessage(title='Bad Wolf', content='Rose Tyler') result = view.render() assert result.content_type == 'application/json' assert result.unicode_body data = json.loads(result.unicode_body) assert data['title'] == 'Bad Wolf' assert data['content'] == 'Rose Tyler'