def testToggleItem(self): cc = CategoricalCondition(data=self.table, attr='fake_cat') cc.add_category(['C1', 'C3']) cc.toggle_category('C1') cc.toggle_category('C2') self.assertEqual(set(cc.included_categories()), set(['C3', 'C2'])) cc.toggle_category(['C2','C4']) self.assertEqual(set(cc.included_categories()), set(['C3', 'C4']))
def testExcludeAll(self): cc = CategoricalCondition(data=self.table, attr='fake_cat') cc.add_category('C1') cc.exclude_all() self.assertEqual(cc.included_categories(),[])
def testIncludeAll(self): cc = CategoricalCondition(data=self.table, attr='fake_cat') cc.include_all() self.assertSetEqual(set(cc.included_categories()), set(self.table.distinct('fake_cat')))
def testRemove(self): cc = CategoricalCondition(data=self.table, attr='fake_cat') cc.add_category(['C1', 'C3']) cc.remove_category('C1') self.assertEqual(set(cc.included_categories()), set(['C3']))
def testCreation(self): cc = CategoricalCondition(data=self.table, attr='fake_cat') self.assertEqual(cc.included_categories(), []) with self.assertRaises(NotImplementedError): cc = CategoricalCondition(data=self.table, attr='Information')