import pytest  # noqa
from city_scrapers_core.constants import COMMITTEE, TENTATIVE
from city_scrapers_core.utils import file_response
from freezegun import freeze_time

from city_scrapers.spiders.det_city_council import DetCityCouncilSpider

freezer = freeze_time("2020-09-29")
freezer.start()

test_response = file_response(
    join(dirname(__file__), "files", "det_city_council.html"),
    url="https://pub-detroitmi.escribemeetings.com/Meetings.aspx",
)
spider = DetCityCouncilSpider()
parsed_items = [i for i in spider._parse_upcoming_meetings(test_response)
                ] + [i for i in spider._parse_past_meetings(test_response)]

freezer.stop()


def test_title():
    assert parsed_items[0]["title"] == "City Council Formal Session"


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


def test_start():
Exemple #2
0
import pytest  # noqa
from city_scrapers_core.constants import COMMITTEE, TENTATIVE
from freezegun import freeze_time
from tests.utils import file_response

from city_scrapers.spiders.det_city_council import DetCityCouncilSpider

freezer = freeze_time('2019-02-22')
freezer.start()

test_response = file_response(
    'files/det_city_council.html',
    url=
    'https://detroitmi.gov/events/public-health-and-safety-standing-committee-02-25-19'
)
spider = DetCityCouncilSpider()
item = spider.parse_event_page(test_response)

freezer.stop()


def test_title():
    assert item['title'] == 'Public Health and Safety Standing Committee'


def test_description():
    assert item['description'] == ''


def test_start():
    assert item['start'] == datetime(2019, 2, 25, 10, 0)
import urllib
from datetime import date, time
from urllib.parse import parse_qsl

import pytest
import scrapy
from tests.utils import file_response

from city_scrapers.spiders.det_city_council import DetCityCouncilSpider

test_response = file_response('files/det_city_council.html')
spider = DetCityCouncilSpider()


def test_request_count():
    requests = list(spider.parse(test_response))
    number_next_page_request = 1
    event_requests = 34
    assert len(requests) == number_next_page_request + event_requests

    all_calendar_events = {
        urllib.parse.unquote(request.url)
        for request in requests
        if 'Details' in request.url
    }
    select_calendar_events = {
        "http://www.detroitmi.gov/Government/City-Council/City-Council-Sessions/ModuleID/8319/ItemID/6552/mctl/EventDetails",  # noqa
        "http://www.detroitmi.gov/Government/City-Council/City-Council-Sessions/ModuleID/8319/ItemID/6580/mctl/EventDetails",  # noqa
        "http://www.detroitmi.gov/Government/City-Council/City-Council-Sessions/ModuleID/8319/ItemID/6573/mctl/EventDetails",  # noqa
        "http://www.detroitmi.gov/Government/City-Council/City-Council-Sessions/ModuleID/8319/ItemID/6585/mctl/EventDetails",  # noqa
    }