Exemplo n.º 1
0
def test_engine_stopped_suites_should_run(get_crawler, suites):
    """The suites defined at engine_stopped_suites should be loaded and run"""
    crawler = get_crawler()
    spidermon = Spidermon(crawler, engine_stopped_suites=suites)
    spidermon.engine_stopped_suites[0].run = mock.MagicMock()
    spidermon.engine_stopped()
    assert spidermon.engine_stopped_suites[0].__class__.__name__ == "Suite01"
    spidermon.engine_stopped_suites[0].run.assert_called_once_with(mock.ANY)
Exemplo n.º 2
0
def test_spider_closed_suites_should_run(get_crawler, suites):
    """The suites defined at spider_closed_suites should be loaded and run"""
    crawler = get_crawler()
    spidermon = Spidermon(crawler,
                          spider_opened_suites=suites,
                          spider_closed_suites=suites)
    spidermon.spider_closed_suites[0].run = mock.MagicMock()
    spidermon.spider_opened(crawler.spider)
    spidermon.spider_closed(crawler.spider)
    assert spidermon.spider_closed_suites[0].__class__.__name__ == "Suite01"
    spidermon.spider_closed_suites[0].run.assert_called_once_with(mock.ANY)