Exemple #1
0
import json
from datetime import datetime

import pytest
from city_scrapers_core.constants import BOARD, PASSED

from city_scrapers.spiders.cook_board import CookBoardSpider

test_response = []
with open('tests/files/cook_board.txt') as f:
    for line in f:
        test_response.append(json.loads(line))
spider = CookBoardSpider()
parsed_items = [item for item in spider.parse_legistar(test_response)]


def test_count():
    assert len(parsed_items) == 167


def test_title():
    assert parsed_items[25]['title'] == 'Board of Commissioners'


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


def test_start():
    assert parsed_items[25]['start'] == datetime(2017, 9, 13, 11)
from os.path import dirname, join

import pytest
from city_scrapers_core.constants import BOARD, TENTATIVE
from freezegun import freeze_time
from scrapy.settings import Settings

from city_scrapers.spiders.cook_board import CookBoardSpider

freezer = freeze_time("2017-09-01")
freezer.start()

with open(join(dirname(__file__), "files", "cook_board.json"), "r") as f:
    test_response = json.load(f)

spider = CookBoardSpider()
spider.settings = Settings(values={"CITY_SCRAPERS_ARCHIVE": False})

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

freezer.stop()


def test_count():
    assert len(parsed_items) == 82


def test_title():
    assert parsed_items[25]['title'] == 'Board of Commissioners'

Exemple #3
0
import json
from datetime import date, time

import pytest

from city_scrapers.spiders.cook_board import CookBoardSpider

test_response = []
with open('tests/files/cook_board.txt') as f:
    for line in f:
        test_response.append(json.loads(line))
spider = CookBoardSpider()
parsed_items = [item for item in spider._parse_events(test_response)]


def test_name():
    assert parsed_items[25]['name'] == 'Board of Commissioners'


def test_description():
    assert parsed_items[25]['event_description'] == ''


def test_start():
    EXPECTED_START = {
        'date': date(2017, 9, 13),
        'time': time(11, 00),
        'note': ''
    }
    assert parsed_items[25]['start'] == EXPECTED_START