# Copyright (C) 2006-2012 Mortal Coil Games # See LICENSE for details. """ Test Filter Code """ from twisted.trial.unittest import TestCase from mv3d.reporter.event import Filter, FilterCondition class FilterTest: """ You need to add a docstring here ! """ def __init__(self): self.name = "something" self.age = 22 class Test_FilterCondition(TestCase): """ You need to add a docstring here ! """ def test_constructor(self): """ You need to add a docstring here ! """ t = FilterCondition() self.assertEqual(t.item, "") self.assertEqual(t.test, "") self.assertEqual(t.parameters, []) self.assertEqual(t.positive, 1) def test_addTest(self): """ You need to add a docstring here ! """ t = FilterCondition() l = len(t.tests) t.addTest("SomeTest", 0) self.assertEqual(len(t.tests), l + 1) def test_Item(self): """ You need to add a docstring here ! """ t = FilterCondition() ft = FilterTest() t.item = "name" t.test = "==" t.parameters.append("something") self.assertEqual(t._item(ft), "something") t.item = "age" self.assertEqual(t._item(ft), 22) def test_checkObject(self): """ You need to add a docstring here ! """ t = FilterCondition() ft = FilterTest() t.item = "age" t.test = "==" t.parameters.append(22) self.failUnless(t.checkObject(ft)) t.parameters[0] = 23 self.failIf(t.checkObject(ft)) class Test_Filter(TestCase): """ You need to add a docstring here ! """ def test_Constructor(self): """ You need to add a docstring here ! """ t = Filter() self.assertEqual(t.rules, []) def test_checkObject(self): """ You need to add a docstring here ! """ t = Filter() fc = FilterCondition() ft = FilterTest() fc.item = "name" fc.test = "==" fc.parameters.append("something") t.addRule(fc) self.failUnless(t.checkObject(ft)) ft.name = "otherthing" self.failIf(t.checkObject(ft))