Ejemplo n.º 1
0
    def test_delete_filter(self):
        """Test the delete() method works with QueryFilters."""
        qf1 = QueryFilter(table=self.fake.word(),
                          field=self.fake.word(),
                          parameter=self.fake.word())
        qf2 = QueryFilter(table=self.fake.word(),
                          field=self.fake.word(),
                          parameter=self.fake.word())
        qf_coll = QueryFilterCollection([qf1, qf2])

        qf_coll.delete(qf1)
        self.assertEqual([qf2], qf_coll._filters)
        self.assertNotIn(qf1, qf_coll)
Ejemplo n.º 2
0
    def test_delete_fail(self):
        """Test the delete() method works with QueryFilters."""
        qf1 = QueryFilter(table=self.fake.word(),
                          field=self.fake.word(),
                          parameter=self.fake.word())
        qf2 = QueryFilter(table=self.fake.word(),
                          field=self.fake.word(),
                          parameter=self.fake.word())
        qf_coll = QueryFilterCollection([qf1, qf2])

        q_dict = {
            'table': self.fake.word(),
            'field': self.fake.word(),
            'parameter': self.fake.word()
        }

        with self.assertRaises(AttributeError):
            qf_coll.delete(qf1, **q_dict)