Exemple #1
0
from os.path import dirname, join

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

from city_scrapers.spiders.cook_water import CookWaterSpider

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

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

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

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

freezer.stop()


def test_title():
    assert parsed_items[0]["title"] == "Board of Commissioners"


def test_start():
    assert parsed_items[0]["start"] == datetime(2018, 12, 20, 10, 30)

import json
from datetime import date, time

import pytest

from city_scrapers.constants import BOARD
from city_scrapers.spiders.cook_water import CookWaterSpider

test_response = []
with open('tests/files/cook_water.json') as f:
    test_response.extend(json.loads(f.read()))
spider = CookWaterSpider()
parsed_items = [item for item in spider._parse_events(test_response)]


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


def test_start_time():
    assert parsed_items[0]['start'] == {
        'date': date(2018, 12, 20),
        'time': time(10, 30, 00),
        'note': '',
    }


def test_id():
    assert parsed_items[0][
        'id'] == 'cook_water/201812201030/x/board_of_commissioners'
import json
from datetime import datetime
from os.path import dirname, join

import pytest
from city_scrapers_core.constants import BOARD, PASSED

from city_scrapers.spiders.cook_water import CookWaterSpider

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

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


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


def test_start():
    assert parsed_items[0]['start'] == datetime(2018, 12, 20, 10, 30)


def test_end():
    assert parsed_items[0]['end'] is None


def test_id():
    assert parsed_items[0]['id'] == 'cook_water/201812201030/x/board_of_commissioners'