Beispiel #1
0
 def setUp(self):
     """Create a test source (easier than fixture for now)"""
     source = Source(
         name = 'Test Source',
         url  = 'http://www.mysociety.org/',
         date = datetime.date( 2011, 11, 14),
     )
     source.save()
     self.source = source
Beispiel #2
0
 def setUp(self):
     """Create a test source"""
     source = Source(
         name='Test Source',
         url='http://example.com/whatever',
         date=datetime.date(2011, 11, 14),
     )
     source.save()
     self.source = source
Beispiel #3
0
 def setUp(self):
     """Create a test source"""
     source = Source(
         name = 'Test Source',
         url  = 'http://example.com/whatever',
         date = datetime.date( 2011, 11, 14),
     )
     source.save()
     self.source = source
    def test_possible_matching_speakers(self):
        source = Source(
            name='Test source',
            url='http://example.com/foo/bar/testing',
            date=datetime.date(2011, 1, 3),
        )

        venue = Venue(
            slug='test-venue',
            name='Test Venue',
        )

        sitting = Sitting(
            start_date=datetime.date(2011, 1, 2),
            source=source,
            venue=venue,
        )

        entry = Entry(sitting=sitting, )

        james_smith = Person.objects.create(
            legal_name='James Smith',
            slug='james-smith',
        )

        james_smith2 = Person.objects.create(
            title='Mr',
            legal_name='Bob Smith James',
            slug='james-smith2',
        )

        mp = PositionTitle.objects.create(
            name='Member of Parliament',
            slug='mp',
        )

        Position.objects.create(
            person=james_smith,
            title=mp,
            start_date=ApproximateDate(year=2011, month=1, day=1),
            end_date=ApproximateDate(future=True),
            category='political',
        )

        Position.objects.create(
            person=james_smith2,
            title=mp,
            start_date=ApproximateDate(year=2011, month=1, day=1),
            end_date=ApproximateDate(future=True),
            category='political',
        )

        entry.speaker_name = 'James Smith'
        speakers = entry.possible_matching_speakers(
            name_matching_algorithm=NAME_SUBSTRING_MATCH)
        self.assertListEqual(list(speakers), [james_smith])

        entry.speaker_name = 'Mr Smith'
        speakers = entry.possible_matching_speakers(
            name_matching_algorithm=NAME_SUBSTRING_MATCH)
        self.assertItemsEqual(speakers, (james_smith, james_smith2))

        speakers = entry.possible_matching_speakers(
            name_matching_algorithm=NAME_SET_INTERSECTION_MATCH)
        self.assertListEqual(list(speakers), [james_smith2])

        entry.speaker_name = 'Mr James Smith'
        speakers = entry.possible_matching_speakers(
            name_matching_algorithm=NAME_SUBSTRING_MATCH)
        self.assertListEqual(list(speakers), [james_smith])

        speakers = entry.possible_matching_speakers(
            name_matching_algorithm=NAME_SET_INTERSECTION_MATCH)
        self.assertListEqual(list(speakers), [james_smith2, james_smith])