# Shared properties between two different page / meeting types

LOCATION = {
    "name": "DEGC, Guardian Building",
    "address": "500 Griswold St, Suite 2200, Detroit, MI 48226",
}

TITLE = "Board of Directors"

test_response = file_response(
    join(dirname(__file__), "files", "det_local_development_finance_authority.html"),
    url="http://www.degc.org/public-authorities/ldfa/",
)
freezer = freeze_time("2018-07-26")
spider = DetLocalDevelopmentFinanceAuthoritySpider()
spider.settings = Settings(values={"CITY_SCRAPERS_ARCHIVE": False})

freezer.start()
parsed_items = [item for item in spider._next_meetings(test_response)]
freezer.stop()


def test_initial_request_count():
    freezer.start()
    items = list(spider.parse(test_response))
    freezer.stop()
    assert len(items) == 3
    urls = {r.url for r in items if isinstance(r, scrapy.Request)}
    assert urls == {
        "http://www.degc.org/public-authorities/ldfa/fy-2017-2018-meetings/",
    DetLocalDevelopmentFinanceAuthoritySpider)

# Shared properties between two different page / meeting types

LOCATION = {
    'name': 'DEGC, Guardian Building',
    'address': '500 Griswold St, Suite 2200, Detroit, MI 48226'
}

TITLE = 'Board of Directors'

test_response = file_response(
    'files/det_local_development_finance_authority.html',
    url='http://www.degc.org/public-authorities/ldfa/')
freezer = freeze_time('2018-07-26')
spider = DetLocalDevelopmentFinanceAuthoritySpider()
freezer.start()
parsed_items = [item for item in spider._next_meetings(test_response)]
freezer.stop()


def test_initial_request_count():
    items = list(spider.parse(test_response))
    assert len(items) == 3
    urls = {r.url for r in items if isinstance(r, scrapy.Request)}
    assert urls == {
        'http://www.degc.org/public-authorities/ldfa/fy-2017-2018-meetings/',
        'http://www.degc.org/public-authorities/ldfa/ldfa-fy-2016-2017-meetings/'
    }
    items = [i for i in items if not isinstance(i, scrapy.Request)]
    assert len(items) == 1