Add tests for selection faceting for section {8}

This commit is contained in:
Paul Makepeace 2011-04-24 15:31:06 -04:00
parent c7b445e851
commit a2fa25d4e4
1 changed files with 12 additions and 5 deletions

View File

@ -80,8 +80,8 @@ class TutorialTestFacets(RefineTestCase):
def test_basic_facet(self): def test_basic_facet(self):
# {4} # {4}
facet = Facet(column='Party Code') facet = Facet(column='Party Code')
facets = self.project.text_facet(facet) response = self.project.text_facet(facet)
pc = facets.facets[0] pc = response.facets[0]
self.assertEqual(pc.name, 'Party Code') self.assertEqual(pc.name, 'Party Code')
self.assertEqual(pc.choices['D'].count, 3700) self.assertEqual(pc.choices['D'].count, 3700)
self.assertEqual(pc.choices['N'].count, 15) self.assertEqual(pc.choices['N'].count, 15)
@ -91,17 +91,24 @@ class TutorialTestFacets(RefineTestCase):
ethnicity_facet = Facet(column='Ethnicity') ethnicity_facet = Facet(column='Ethnicity')
engine.add_facet(ethnicity_facet) engine.add_facet(ethnicity_facet)
self.project.engine = engine self.project.engine = engine
facets = self.project.text_facet() response = self.project.text_facet()
e = facets.facets[1] e = response.facets[1]
self.assertEqual(e.choices['B'].count, 1255) self.assertEqual(e.choices['B'].count, 1255)
self.assertEqual(e.choices['W'].count, 4469) self.assertEqual(e.choices['W'].count, 4469)
# {7} # {7}
ethnicity_facet.include('B') ethnicity_facet.include('B')
facets = self.project.text_facet()
response = self.project.get_rows() response = self.project.get_rows()
self.assertEqual(response.filtered, 1255) self.assertEqual(response.filtered, 1255)
indexes = [r.index for r in response.rows] indexes = [r.index for r in response.rows]
self.assertEqual(indexes, [1, 2, 3, 4, 6, 12, 18, 26, 28, 32]) self.assertEqual(indexes, [1, 2, 3, 4, 6, 12, 18, 26, 28, 32])
# {8}
response = self.project.text_facet()
pc = response.facets[0]
self.assertEqual(pc.name, 'Party Code')
self.assertEqual(pc.choices['D'].count, 1179)
self.assertEqual(pc.choices['R'].count, 11)
self.assertEqual(pc.blank_choice.count, 46)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()