From a0e4ce60e87890ffaa1362bf189385df01c469ef Mon Sep 17 00:00:00 2001 From: Paul Makepeace Date: Tue, 26 Apr 2011 19:31:10 -0400 Subject: [PATCH] Add NumericFacet.reset that clears the range (from, to) --- google/refine/facet.py | 7 ++++++- google/test/test_tutorial.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/google/refine/facet.py b/google/refine/facet.py index edba48f..c76f29f 100644 --- a/google/refine/facet.py +++ b/google/refine/facet.py @@ -115,7 +115,7 @@ class NumericFacet(Facet): column, From=From, to=to, - expression=expression, + expression=expression, type='range', select_blank=select_blank, select_error=select_error, @@ -123,6 +123,11 @@ class NumericFacet(Facet): select_numeric=select_numeric, **options) + def reset(self): + self.From = None + self.to = None + return self + class FacetResponse(object): def __init__(self, facet): diff --git a/google/test/test_tutorial.py b/google/test/test_tutorial.py index 5eb63fa..3c0e978 100644 --- a/google/test/test_tutorial.py +++ b/google/test/test_tutorial.py @@ -421,6 +421,18 @@ class TutorialTestWebScraping(refinetest.RefineTestCase): self.assertEqual(len(rows), 2) self.assertEqual(rows[-1]['top'], 567) self.project.engine.remove_all() + # {5} - tutorial says 'line'; it means 'top' + line_facet = facet.NumericFacet('top') + line_facet.to = 100 + self.project.remove_rows(line_facet) + self.assertInResponse('Remove 775 rows') + line_facet.From = 570 + line_facet.to = 600 + self.project.remove_rows(line_facet) + self.assertInResponse('Remove 71 rows') + line_facet.reset() + response = self.project.get_rows() + self.assertEqual(response.filtered, 4563) if __name__ == '__main__':