コード例 #1
0
from tests.utils import file_response
from city_scrapers.constants import BOARD, PASSED
from city_scrapers.spiders.chi_library import ChiLibrarySpider

# Use betamax to record requests
session = requests.Session()
recorder = betamax.Betamax(session)
with recorder.use_cassette('test_chi_library_libinfo'):
    test_response = file_response(
        'files/chi_library.html',
        url=(
            'https://www.chipublib.org/'
            'board-of-directors/board-meeting-schedule/'
        ),
    )
    spider = ChiLibrarySpider(session=session)
    parsed_items = [
        item for item in spider.parse(test_response)
        if isinstance(item, dict)
    ]


def test_name():
    assert parsed_items[0]['name'] == 'Board of Directors'


def test_description():
    assert parsed_items[0]['description'] == (
        'There are no meetings in February, July and August. '
        'Entry into these meetings is permitted at 8:45 a.m.'
    )
コード例 #2
0
from city_scrapers.constants import BOARD, CONFIRMED
from city_scrapers.spiders.chi_library import ChiLibrarySpider

freezer = freeze_time('2018-12-20')
freezer.start()
session = MagicMock()
res_mock = MagicMock()
res_mock.status_code = 200
session.get.return_value = res_mock
test_response = file_response(
    'files/chi_library.html',
    url=('https://www.chipublib.org/'
         'board-of-directors/board-meeting-schedule/'),
)
spider = ChiLibrarySpider(session=session)
parsed_items = [
    item for item in spider.parse(test_response) if isinstance(item, dict)
]
freezer.stop()


def test_name():
    assert parsed_items[0]['name'] == 'Board of Directors'


def test_description():
    assert parsed_items[0]['description'] == ''


def test_start():