# Copyright (C) 2006-2012 Mortal Coil Games # See LICENSE for details. """ Event Subscription Tests """ from twisted.trial.unittest import TestCase from mv3d.reporter.event import Event, EventSubscription from mv3d.reporter.event import FilterCondition, Filter from mv3d.util.date import Date class EventNoun: """ You need to add a docstring here ! """ def __init__(self, name): self.name = name def getName(self): """ You need to add a docstring here ! """ return self.name class Test_EventSubscription(TestCase): """ You need to add a docstring here ! """ def receiveEvent(self, e): """ You need to add a docstring here ! """ self.event = e def setUp(self): """ You need to add a docstring here ! """ self.event = 0 def test_receiveEvent(self): """ You need to add a docstring here ! """ t = EventSubscription(self.receiveEvent) e = Event() e.setCategory("Test") e.setSubject(EventNoun("Mike")) e.setVerb("likes") e.setObject("pizza") t.receiveEvent(e) self.assertEqual(self.event, 0) f = Filter() fc = FilterCondition() fc.item = "date" fc.test = ">" fc.addParameter(Date().parse("yesterday")) f.addRule(fc) t.addFilter(f) t.receiveEvent(e) self.assertNotEqual(self.event, 0)