freezer.start() test_response = file_response( join(dirname(__file__), "files", "chi_teacherpension.html"), url="https://www.ctpf.org/board-trustees-meeting-minutes", ) with open(join(dirname(__file__), "files", "chi_teacherpension.xml"), "r") as f: file_content = f.read() feed_url = "https://www.boarddocs.com/il/ctpf/board.nsf/XML-ActiveMeetings" test_feed_response = XmlResponse(url=feed_url, request=Request(url=feed_url), body=str.encode(file_content)) spider = ChiTeacherPensionSpider() spider._parse_minutes(test_response) parsed_items = [item for item in spider._parse_boarddocs(test_feed_response)] freezer.stop() def test_title(): assert parsed_items[0]['title'] == 'Investment Committee' assert parsed_items[1]['title'] == 'Board of Trustees' def test_start(): assert parsed_items[0]['start'] == datetime(2018, 10, 25) assert parsed_items[1]['start'] == datetime(2018, 10, 18, 9, 30)
from datetime import date, time import pytest from freezegun import freeze_time from tests.utils import file_response from city_scrapers.constants import BOARD, CONFIRMED, TENTATIVE from city_scrapers.spiders.chi_teacherpension import ChiTeacherPensionSpider freezer = freeze_time('2018-10-30 12:00:00') freezer.start() test_response = file_response('files/chi_teacherpension.htm') spider = ChiTeacherPensionSpider() parsed_items = [ item for item in spider.parse(test_response) if isinstance(item, dict) ] freezer.stop() def test_name(): assert parsed_items[0]['name'] == 'Regular Board Meeting' def test_start_time(): assert parsed_items[0]['start'] == { 'date': date(2018, 11, 13), 'time': time(9, 30), 'note': '' }