Пример #1
0
    def testEnablingChanges(self):
        cs = ConditionSet(name='condition_set', data=self.table, setop='AND')
        cc = CategoricalCondition(data=self.table, attr='fake_cat')
        rc = RangeCondition(data=self.table, attr='Information')
        rc.set_range(0.5, relative=True)

        cs.add_condition(cc)
        cc.add_category('C1')
        self.assertItemsEqual(cs.reference, self.fake_sets['C1'])
        cc.disable()
        print cs.query, cs.reference
        self.assertItemsEqual(cs.reference, [])

        cs.add_condition(rc)
        self.assertItemsEqual(cs.reference, ['CA', 'NY'])
        rc.enable(False)
        cc.enable()
        self.assertItemsEqual(cs.reference, self.fake_sets['C1'])

        cc.toggle_category(['C1', 'C3'])
        rc.enable()
        self.assertItemsEqual(cs.reference, ['NY'])

        rc.set_range(0, 1, relative=True)
        self.assertItemsEqual(cs.reference, self.fake_sets['C3'])
Пример #2
0
 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']))
Пример #3
0
    def testAddSeveralConditions(self):
        cs = ConditionSet(name='condition_set', data=self.table, setop='AND')
        cc = CategoricalCondition(data=self.table, attr='fake_cat')
        rc = RangeCondition(data=self.table, attr='Information')
        rc.set_range(0.5, relative=True)

        cs.add_condition(cc)
        cc.add_category('C1')
        self.assertItemsEqual(cs.reference, self.fake_sets['C1'])

        cs.add_condition(rc)
        self.assertItemsEqual(cs.reference, ['CA'])

        cc.toggle_category(['C1', 'C3'])
        self.assertItemsEqual(cs.reference, ['NY'])

        rc.set_range(0, 1, relative=True)
        self.assertItemsEqual(cs.reference, self.fake_sets['C3'])