Make facet methods chainable.

This commit is contained in:
Paul Makepeace 2011-04-25 23:13:41 -04:00
parent 364bed871b
commit a65ad6fce1
2 changed files with 5 additions and 0 deletions

View File

@ -70,13 +70,16 @@ class TextFacet(Facet):
if s['v']['v'] == value:
return
self.selection.append({'v': {'v': value, 'l': value}})
return self
def exclude(self, value):
self.selection = [s for s in self.selection
if s['v']['v'] != value]
return self
def reset(self):
self.selection = []
return self
class StarredFacet(TextFacet):

View File

@ -79,6 +79,8 @@ class FacetTest(unittest.TestCase):
self.assertEqual(len(facet.selection), 1)
facet.reset()
self.assertEqual(len(facet.selection), 0)
facet.include('element').include('element 2')
self.assertEqual(len(facet.selection), 2)
def test_reset_remove(self):
text_facet1 = TextFacet('column name')