Exemplo n.º 1
0
from os.path import dirname, join

import pytest
from city_scrapers_core.constants import COMMISSION, PASSED
from city_scrapers_core.utils import file_response
from freezegun import freeze_time
from scrapy.settings import Settings

from city_scrapers.spiders.chi_community_development import ChiCommunityDevelopmentSpider

test_response = file_response(
    join(dirname(__file__), "files", "chi_community_development.html"),
    url=
    'https://www.chicago.gov/city/en/depts/dcd/supp_info/community_developmentcommission.html'
)
spider = ChiCommunityDevelopmentSpider()
spider.settings = Settings(values={"CITY_SCRAPERS_ARCHIVE": False})

freezer = freeze_time("2018-05-01")
freezer.start()

parsed_items = [item for item in spider.parse(test_response)]

freezer.stop()


def test_meeting_count():
    assert len(parsed_items) == 20


def test_unique_id_count():
Exemplo n.º 2
0
from datetime import datetime

import pytest
from city_scrapers_core.constants import COMMISSION, PASSED
from tests.utils import file_response

from city_scrapers.spiders.chi_community_development import ChiCommunityDevelopmentSpider

test_response = file_response(
    'files/chi_development_community_developmentcommission.html',
    'https://www.chicago.gov/city/en/depts/dcd/supp_info/community_developmentcommission.html'
)
spider = ChiCommunityDevelopmentSpider()
parsed_items = [item for item in spider.parse(test_response)]


def test_meeting_count():
    # 12 mtgs / yr * 10 yrs + 3 extra (2016)
    assert len(parsed_items) == 123


def test_unique_id_count():
    assert len(set([item['id'] for item in parsed_items])) == 123


def test_title():
    assert parsed_items[0]['title'] == 'Commission'


def test_description():
    assert parsed_items[0]['description'] == ''
Exemplo n.º 3
0
from datetime import date, time

import pytest
from tests.utils import file_response

from city_scrapers.constants import COMMISSION
from city_scrapers.spiders.chi_community_development import ChiCommunityDevelopmentSpider

test_response = file_response(
    'files/chi_development_community_developmentcommission.html',
    'https://www.cityofchicago.org/city/en/depts/dcd/supp_info/community_developmentcommission.html'
)
spider = ChiCommunityDevelopmentSpider()
parsed_items = [
    item for item in spider.parse(test_response) if isinstance(item, dict)
]


def test_meeting_count():
    # 12 mtgs / yr * 10 yrs + 3 extra (2016)
    assert len(parsed_items) == 123


def test_unique_id_count():
    assert len(set([item['id'] for item in parsed_items])) == 123


def test__type():
    assert parsed_items[0]['_type'] == 'event'