示例#1
0
 def parse_bills(self, bills_json, person_id):
     bills = []
     for bill in bills_json['results']:
         if self.is_person_primary_sponsor(bill, person_id):
             b = Bill(
                 bill['identifier'],
                 bill['title'].strip(),
                 bill['classification'],
                 bill['id'],
             )
             bills.append(b)
     return bills
示例#2
0
def load_archive():
    """Load all bills from a CSV file"""
    app = setup(app_config=APP_CONFIG)
    log.setLevel(logging.INFO)
    with open(sys.argv[1], 'r') as f:
        reader = csv.DictReader(f)
        rows = [
            Bill(
                r['identifier'],
                r['title'].strip(),
                r['classification'],
                r['ocd_id'] or 'NA',
                r['date'],
            ) for r in reader
        ]

    log.info(f'loading all: {len(rows)} introductions')
    log.setLevel(logging.WARNING)
    save_introductions(app.bills, rows)
示例#3
0
def test_shorten_with_reply():
    # seems like @username should not count against 280 chars, based on twitter api docs
    # however when trying to update status starting with @username it was being counted
    # against total.
    bot = TwitterBot(TwitterCredentials('', '', '', ''))
    user_name = 'username'
    bill = Bill(
        'O2018-6573',
        'Restructuring of debt to approve settlement payment from original owner NHS Redevelopment Corp., '
        'and allow multiple property transfers, restructuring of City loans, affordability restrictions and '
        'project rehabilitation agreements with new owner, Villa Capital Partners LLC and Villa Capital '
        'Managers LLC', ['ordinance'],
        'ocd-bill/c08ea55e-4017-4dfa-bfca-604b0eba0e85', '2018-07-25', -1)
    shortened_bill = bot.shorten(bill, user_name)

    assert len(tweet_after_url_shortening(shortened_bill,
                                          user_name)) == TWITTER_MAX_CHARS
    assert tweet_after_url_shortening(shortened_bill, user_name) == \
           '@username Restructuring of debt to approve settlement payment from original owner NHS Redevelopment ' \
           'Corp., and allow multiple property transfers, restructuring of City loans, affordability restrictions and ' \
           'project rehabilitation agreements wi... O2018-6573 xxxxxxxxxxxxxxxxxxxxxxx'
示例#4
0
import pytest

from tweet.bills import Bill

EXPECTED_IDENTIFIER = 'O2018-6138'
EXPECTED_TITLE = 'Fifty-fifth amending agreement with SomerCor 504, Inc. regarding Small Business Improvement Fund ' \
                 'program increases within Jefferson Park, Lawrence/Pulaski and Lincoln Avenue areas'
EXPECTED_CLASSIFICATION = ['ordinance']
EXPECTED_OCD_ID = 'ocd-bill/fdff8130-549a-45ed-9517-01419fdbeb54'
EXPECTED_DATE = '2018-07-25'
EXPECTED_BILL = Bill(EXPECTED_IDENTIFIER, EXPECTED_TITLE, EXPECTED_CLASSIFICATION, EXPECTED_OCD_ID, EXPECTED_DATE, None)
EXAMPLE_INTRODUCTIONS = [
    Bill('O2099-1111', 'Make it illegal to put ketchup on hotdogs', ['ordinance'], 'ocd-bill/hash1', '10/28/18', '123'),
    Bill('O2098-1112', 'Dye the lake green everyday', ['ordinance'], 'ocd-bill/hash2', '10/27/18', '456'),
]


def pytest_addoption(parser):
    parser.addoption(
        "--runslow", action="store_true", default=False, help="run slow tests"
    )


def pytest_collection_modifyitems(config, items):
    if config.getoption("--runslow"):
        # --runslow given in cli: do not skip slow tests
        return
    skip_slow = pytest.mark.skip(reason="need --runslow option to run")
    for item in items:
        if "slow" in item.keywords:
            item.add_marker(skip_slow)