<s> from __future__ import unicode_literals <EOL> import os <EOL> from scrapy . exceptions import CloseSpider <EOL> from scraper . models import Event <EOL> from scraper . scraper_test import EventSpider , ScraperTest <EOL> from dynamic_scraper . models import Checker , SchedulerRuntime <EOL> class ScraperJSRunTest ( ScraperTest ) : <EOL> def setUpScraperJSDefaultScraper ( self ) : <EOL> self . event_website . url = os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . event_website . save ( ) <EOL> def setUpScraperJSDockerScraper ( self ) : <EOL> self . event_website . url = os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . event_website . save ( ) <EOL> self . rpt_mp . render_javascript = True <EOL> self . rpt_mp . dont_filter = True <EOL> self . rpt_mp . save ( ) <EOL> self . rpt_dp1 . render_javascript = True <EOL> self . rpt_dp1 . dont_filter = True <EOL> self . rpt_dp1 . save ( ) <EOL> def setUpScraperJSChecker ( self , path ) : <EOL> super ( ScraperJSRunTest , self ) . setUp ( ) <EOL> self . checker = Checker ( ) <EOL> self . checker . scraped_obj_attr = self . soa_url <EOL> self . checker . scraper = self . scraper <EOL> self . checker . checker_type = '<STR_LIT:X>' <EOL> self . checker . checker_x_path = '<STR_LIT>' <EOL> self . checker . checker_ref_url = path + '<STR_LIT>' <EOL> self . checker . save ( ) <EOL> scheduler_rt = SchedulerRuntime ( ) <EOL> scheduler_rt . save ( ) <EOL> self . event = Event ( title = '<STR_LIT>' , event_website = self . event_website , <EOL> description = '<STR_LIT>' , <EOL> url = path + '<STR_LIT>' , <EOL> checker_runtime = scheduler_rt ) <EOL> self . event . save ( ) <EOL> def setUpScraperJSDefaultChecker ( self ) : <EOL> self . setUpScraperJSChecker ( '<STR_LIT>' ) <EOL> def setUpScraperJSDockerChecker ( self ) : <EOL> self . setUpScraperJSChecker ( '<STR_LIT>' ) <EOL> self . rpt_dp1 . render_javascript = True <EOL> self . rpt_dp1 . save ( ) <EOL> def test_default_no_scrapyjs_main_page ( self ) : <EOL> self . setUpScraperJSDefaultScraper ( ) <EOL> self . run_event_spider ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:1> ) <EOL> def test_default_no_scrapyjs_detail_page ( self ) : <EOL> self . setUpScraperJSDefaultScraper ( ) <EOL> self . run_event_spider ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . filter ( description = '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> def test_activated_scrapyjs_main_page ( self ) : <EOL> self . setUpScraperJSDockerScraper ( ) <EOL> self . run_event_spider ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:2> ) <EOL> def test_activated_scrapyjs_detail_page ( self ) : <EOL> self . setUpScraperJSDockerScraper ( ) <EOL> self . run_event_spider ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . filter ( description = '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> def test_only_main_page_scrapyjs_main_page ( self ) : <EOL> self . setUpScraperJSDockerScraper ( ) <EOL> self . event_website . url = os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . event_website . save ( ) <EOL> self . rpt_dp1 . render_javascript = False <EOL> self . rpt_dp1 . save ( ) <EOL> self . run_event_spider ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( Event . objects . filter ( description = '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . filter ( description = '<STR_LIT>' ) ) , <NUM_LIT:0> ) <EOL> def test_default_no_scrapyjs_checker_delete ( self ) : <EOL> self . setUpScraperJSDefaultChecker ( ) <EOL> self . checker . checker_x_path_result = '<STR_LIT>' <EOL> self . checker . save ( ) <EOL> self . run_event_checker ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:0> ) <EOL> def test_default_no_scrapyjs_checker_no_delete ( self ) : <EOL> self . setUpScraperJSDefaultChecker ( ) <EOL> self . checker . checker_x_path_result = '<STR_LIT>' <EOL> self . checker . save ( ) <EOL> self . run_event_checker ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:1> ) <EOL> def test_activated_scrapyjs_checker_delete ( self ) : <EOL> self . setUpScraperJSDockerChecker ( ) <EOL> self . checker . checker_x_path_result = '<STR_LIT>' <EOL> self . checker . save ( ) <EOL> self . run_event_checker ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:0> ) <EOL> def test_activated_scrapyjs_checker_no_delete ( self ) : <EOL> self . setUpScraperJSDockerChecker ( ) <EOL> self . checker . checker_x_path_result = '<STR_LIT>' <EOL> self . checker . save ( ) <EOL> self . run_event_checker ( <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( Event . objects . all ( ) ) , <NUM_LIT:1> ) </s>
