Beispiel #1
0
def test_create_posts_simple():
    d = Division.objects.create(id="ocd-division/country:us/state:al",
                                name="Alabama")
    j = Jurisdiction.objects.create(
        id="ocd-jurisdiction/country:us/state:al/government",
        name="Alabama",
        division=d)
    Organization.objects.create(jurisdiction=j,
                                name="House",
                                classification="lower")
    Organization.objects.create(jurisdiction=j,
                                name="Senate",
                                classification="upper")
    settings = {
        "lower_seats": 105,
        "upper_seats": 35,
        "legislature_name": "Alabama Legislature"
    }
    # divisions would already exist
    for n in range(settings["lower_seats"] + 1):
        Division.objects.create(
            id=f"ocd-division/country:us/state:al/sldl:{n}", name=str(n))
    for n in range(settings["upper_seats"] + 1):
        Division.objects.create(
            id=f"ocd-division/country:us/state:al/sldu:{n}", name=str(n))

    create_posts(j.id, settings)

    assert Post.objects.filter(role="Senator").count() == 35
    assert Post.objects.filter(role="Representative").count() == 105
Beispiel #2
0
def test_create_posts_simple():
    d = Division.objects.create(id='ocd-division/country:us/state:al',
                                name='Alabama')
    j = Jurisdiction.objects.create(
        id='ocd-jurisdiction/country:us/state:al/government',
        name='Alabama',
        division=d)
    Organization.objects.create(jurisdiction=j,
                                name='House',
                                classification='lower')
    Organization.objects.create(jurisdiction=j,
                                name='Senate',
                                classification='upper')
    settings = {
        'lower_seats': 105,
        'upper_seats': 35,
        'legislature_name': 'Alabama Legislature',
    }
    # divisions would already exist
    for n in range(settings['lower_seats'] + 1):
        Division.objects.create(
            id=f'ocd-division/country:us/state:al/sldl:{n}', name=str(n))
    for n in range(settings['upper_seats'] + 1):
        Division.objects.create(
            id=f'ocd-division/country:us/state:al/sldu:{n}', name=str(n))

    create_posts(j.id, settings)

    assert Post.objects.filter(role='Senator').count() == 35
    assert Post.objects.filter(role='Representative').count() == 105
Beispiel #3
0
def test_create_top_level_unicameral():
    d = Division.objects.create(id="ocd-division/country:us/district:dc",
                                name="DC")
    j = Jurisdiction.objects.create(
        id="ocd-jurisdiction/country:us/district:dc/government",
        name="DC",
        division=d)
    org = Organization.objects.create(jurisdiction=j,
                                      name="Council",
                                      classification="legislature")
    for n in range(1, 9):
        Division.objects.create(
            id=f"ocd-division/country:us/district:dc/ward:{n}",
            name=f"Ward {n}")

    settings = yaml.load("""
legislature_seats: {'Ward 1': 1, 'Ward 2': 1, 'Ward 3': 1, 'Ward 4': 1, 'Ward 5': 1,
                    'Ward 6': 1, 'Ward 7': 1, 'Ward 8': 1, 'Chairman': 1, 'At-Large': 4}
legislature_name: Council of the District of Columbia
legislature_title: Councilmember
legislature_division_ids:
    'Ward 1': 'ocd-division/country:us/district:dc/ward:1'
    'Ward 2': 'ocd-division/country:us/district:dc/ward:2'
    'Ward 3': 'ocd-division/country:us/district:dc/ward:3'
    'Ward 4': 'ocd-division/country:us/district:dc/ward:4'
    'Ward 5': 'ocd-division/country:us/district:dc/ward:5'
    'Ward 6': 'ocd-division/country:us/district:dc/ward:6'
    'Ward 7': 'ocd-division/country:us/district:dc/ward:7'
    'Ward 8': 'ocd-division/country:us/district:dc/ward:8'
    'Chairman': 'ocd-division/country:us/district:dc'
    'At-Large': 'ocd-division/country:us/district:dc'""")

    create_posts(j.id, settings)
    assert org.posts.all().count() == 10
    assert Post.objects.filter(
        division_id="ocd-division/country:us/district:dc").count() == 2