コード例 #1
0
def test_jurisdiction_bicameral_scrape():
    j = FakeJurisdiction()
    js = JurisdictionScraper(j, '/tmp/')
    objects = list(js.scrape())
    obj_names = set()
    obj_types = defaultdict(int)

    for o in objects:
        obj_names.add(o.name)
        obj_types[type(o)] += 1

    # ensure Jurisdiction and 5 organizations were found
    assert obj_names == {'Test', 'Congress', 'House', 'Senate', 'Democratic', 'Republican'}
    assert obj_types[FakeJurisdiction] == 1
    assert obj_types[Organization] == 5
コード例 #2
0
def test_jurisdiction_bicameral_scrape():
    j = FakeJurisdiction()
    js = JurisdictionScraper(j, '/tmp/')
    objects = list(js.scrape())
    obj_names = set()
    obj_types = defaultdict(int)

    for o in objects:
        obj_names.add(o.name)
        obj_types[type(o)] += 1

    # ensure Jurisdiction and 5 organizations were found
    assert obj_names == {'Test', 'Congress', 'House', 'Senate'}
    assert obj_types[FakeJurisdiction] == 1
    assert obj_types[Organization] == 3
コード例 #3
0
def test_jurisdiction_unicam_scrape():
    class UnicameralJurisdiction(Jurisdiction):
        jurisdiction_id = 'unicam'
        name = 'Unicameral'
        url = 'http://example.com'

    j = UnicameralJurisdiction()
    js = JurisdictionScraper(j, '/tmp/')
    objects = list(js.scrape())

    # two objects, first is the Jurisdiction
    assert len(objects) == 2
    assert objects[0] == j

    # ensure we made a single legislature org as well
    assert isinstance(objects[1], Organization)
    assert objects[1].classification == 'legislature'
    assert objects[1].sources[0]['url'] == j.url
コード例 #4
0
def test_jurisdiction_unicam_scrape():
    class UnicameralJurisdiction(Jurisdiction):
        jurisdiction_id = 'unicam'
        name = 'Unicameral'
        url = 'http://example.com'

        def get_organizations(self):
            yield Organization('Unicameral Legislature',
                               classification='legislature')

    j = UnicameralJurisdiction()
    js = JurisdictionScraper(j, '/tmp/')
    objects = list(js.scrape())

    # two objects, first is the Jurisdiction
    assert len(objects) == 2
    assert objects[0] == j

    # ensure we made a single legislature org
    assert isinstance(objects[1], Organization)
    assert objects[1].classification == 'legislature'