def test_merge_activity(session):
    from mptracker.scraper.proposals import ProposalScraper

    PROP_URL_CDEP = PROPOSAL_URL + "idp=13037&cam=2"
    PROP_URL_SENATE = PROPOSAL_URL + "idp=17003&cam=1"

    session.url_map.update(
        {PROP_URL_CDEP: PAGES_DIR / "proposal-2-13037", PROP_URL_SENATE: PAGES_DIR / "proposal-1-17003"}
    )

    scraper = ProposalScraper(session)
    activity = scraper.merge_activity(
        scraper.get_activity(scraper.fetch_url(PROP_URL_CDEP)), scraper.get_activity(scraper.fetch_url(PROP_URL_SENATE))
    )
    assert activity[3].date == date(2013, 2, 12)
    assert "înregistrat la Senat pentru dezbatere" in activity[3].html
    assert "cu nr.b38 (adresa nr.bpi19/11-02-2013)" in activity[3].html
    assert activity[4].date == date(2013, 2, 19)
    assert "trimis pentru aviz la Consiliul legislativ" in activity[4].html
def test_merge_activity(session):
    from mptracker.scraper.proposals import ProposalScraper
    PROP_URL_CDEP = PROPOSAL_URL + 'idp=13037&cam=2'
    PROP_URL_SENATE = PROPOSAL_URL + 'idp=17003&cam=1'

    session.url_map.update({
        PROP_URL_CDEP: PAGES_DIR / 'proposal-2-13037',
        PROP_URL_SENATE: PAGES_DIR / 'proposal-1-17003',
    })

    scraper = ProposalScraper(session)
    activity = scraper.merge_activity(
        scraper.get_activity(scraper.fetch_url(PROP_URL_CDEP)),
        scraper.get_activity(scraper.fetch_url(PROP_URL_SENATE)))
    assert activity[3].date == date(2013, 2, 12)
    assert "înregistrat la Senat pentru dezbatere" in activity[3].html
    assert "cu nr.b38 (adresa nr.bpi19/11-02-2013)" in activity[3].html
    assert activity[4].date == date(2013, 2, 19)
    assert "trimis pentru aviz la Consiliul legislativ" in activity[4].html
def test_get_activity(session):
    from mptracker.scraper.proposals import ProposalScraper

    PROP_URL = "http://www.cdep.ro/pls/proiecte/upl_pck.proiect?idp=13037"

    session.url_map.update({PROP_URL: PAGES_DIR / "proposal-2-13037"})

    scraper = ProposalScraper(session)
    page = scraper.fetch_url(PROP_URL)
    activity = scraper.get_activity(page)
    assert "prezentare în Biroul Permanent" in activity[0].html
    assert activity[0].location == "CD"
    assert activity[0].date == date(2013, 2, 11)
    assert activity[3].date == date(2013, 6, 5)
    assert "la Camera Deputaţilor pentru dezbatere" in activity[3].html
    assert "trimis pentru aviz la" in activity[3].html
    assert activity[4].date == date(2013, 6, 13)
    assert activity[-1].date == date(2013, 6, 25)
    assert "primire aviz de la" in activity[-1].html
    assert "Comisia pentru sănătate şi familie" in activity[-1].html
    assert "(pdf)" in activity[-1].html
def test_get_activity(session):
    from mptracker.scraper.proposals import ProposalScraper
    PROP_URL = 'http://www.cdep.ro/pls/proiecte/upl_pck.proiect?idp=13037'

    session.url_map.update({
        PROP_URL: PAGES_DIR / 'proposal-2-13037',
    })

    scraper = ProposalScraper(session)
    page = scraper.fetch_url(PROP_URL)
    activity = scraper.get_activity(page)
    assert "prezentare în Biroul Permanent" in activity[0].html
    assert activity[0].location == 'CD'
    assert activity[0].date == date(2013, 2, 11)
    assert activity[3].date == date(2013, 6, 5)
    assert "la Camera Deputaţilor pentru dezbatere" in activity[3].html
    assert "trimis pentru aviz la" in activity[3].html
    assert activity[4].date == date(2013, 6, 13)
    assert activity[-1].date == date(2013, 6, 25)
    assert "primire aviz de la" in activity[-1].html
    assert "Comisia pentru sănătate şi familie" in activity[-1].html
    assert '(pdf)' in activity[-1].html