コード例 #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"}
    assert obj_types[FakeJurisdiction] == 1
    assert obj_types[Organization] == 3
コード例 #2
0
def test_jurisdiction_unicam_scrape():
    class Nebraska(State):
        pass

    j = Nebraska()
    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"
コード例 #3
0
def test_jurisdiction_bicameral_scrape():
    j = NewJersey()
    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 3 organizations were found
    assert obj_names == {
        "New jersey Legislature", "Assembly", "New Jersey", "Senate"
    }
    assert obj_types[NewJersey] == 1
    assert obj_types[Organization] == 3
コード例 #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"