scraper.models.Event

Here are the examples of the python api scraper.models.Event taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

Example 1

View license
    def extraSetUpHTMLChecker(self):
        self.checker = Checker()
        self.checker.scraped_obj_attr = self.soa_url
        self.checker.scraper = self.scraper
        self.checker.checker_type = 'X'
        self.checker.checker_x_path = '//div[@class="event_not_found"]/div/text()'
        self.checker.checker_x_path_result = 'Event not found!'
        self.checker.checker_ref_url = 'http://localhost:8010/static/site_with_json_content_type/event_not_found.html'
        self.checker.save()
        
        scheduler_rt = SchedulerRuntime()
        scheduler_rt.save()
        
        self.event = Event(title='Event 1', event_website=self.event_website,
            description='Event 1 description', 
            url='http://localhost:8010/static/site_with_json_content_type/event_not_found.html',
            checker_runtime=scheduler_rt)
        self.event.save()

Example 2

View license
    def setUpScraperJSChecker(self, path):
        super(ScraperJSRunTest, self).setUp()
        
        self.checker = Checker()
        self.checker.scraped_obj_attr = self.soa_url
        self.checker.scraper = self.scraper
        self.checker.checker_type = 'X'
        self.checker.checker_x_path = '//div[@class="event_not_found"]/div/text()'
        self.checker.checker_ref_url = path + 'site_with_js/event_not_found.html'
        self.checker.save()
        
        scheduler_rt = SchedulerRuntime()
        scheduler_rt.save()
        
        self.event = Event(title='Event 1', event_website=self.event_website,
            description='Event 1 description', 
            url=path + 'site_with_js/event_not_found.html',
            checker_runtime=scheduler_rt)
        self.event.save()

Example 3

View license
    def test_double(self):
        checker_rt = SchedulerRuntime()
        checker_rt.save()
        event = Event(title='Event 1', event_website=self.event_website, 
            url='http://localhost:8010/static/site_generic/event1.html',
            checker_runtime=checker_rt)
        event.save()
        self.run_event_spider(1)
        
        self.assertEqual(len(Event.objects.all()), 4)
        self.assertEqual(len(Event.objects.filter(title='Event 1')), 1)

Example 4

View license
    def test_detail_page_url_id_field(self):
        checker_rt = SchedulerRuntime()
        checker_rt.save()
        event = Event(title='Event 1', event_website=self.event_website, 
            url='http://localhost:8010/static/site_generic/event5.html',
            checker_runtime=checker_rt)
        event.save()
        self.run_event_spider(1)
        
        self.assertEqual(len(Event.objects.all()), 5)
        self.assertEqual(Event.objects.filter(title='Event 1').count(), 2)

Example 5

View license
    def test_single_standard_id_field(self):
        checker_rt = SchedulerRuntime()
        checker_rt.save()
        event = Event(title='Event 1', event_website=self.event_website, 
            url='http://localhost:8010/static/site_generic/event5.html',
            checker_runtime=checker_rt)
        event.save()
        self.soa_url.id_field = False
        self.soa_url.save()
        self.soa_title.id_field = True
        self.soa_title.save()
        self.run_event_spider(1)
        
        self.assertEqual(len(Event.objects.all()), 4)
        self.assertEqual(Event.objects.filter(title='Event 1').count(), 1)

Example 6

View license
    def test_standard_update_field_update(self):
        checker_rt = SchedulerRuntime()
        checker_rt.save()
        event = Event(title='Event 1 - Old Title', event_website=self.event_website, 
            url='http://localhost:8010/static/site_generic/event1.html',
            checker_runtime=checker_rt)
        event.save()
        self.soa_title.attr_type = 'T'
        self.soa_title.save()
        
        self.run_event_spider(1)
        
        event_updated = Event.objects.get(pk=event.id)
        self.assertEqual(event_updated.title, 'Event 1')
        self.assertEqual(len(Event.objects.filter(title='Event 1 - Old Title')), 0)

Example 7

View license
    def setUp(self):
        super(CheckerRunTest, self).setUp()
        
        self.checker = Checker()
        self.checker.scraped_obj_attr = self.soa_url
        self.checker.scraper = self.scraper
        self.checker.checker_type = 'X'
        self.checker.checker_x_path = '//div[@class="event_not_found"]/div/text()'
        self.checker.checker_x_path_result = 'Event was deleted!'
        self.checker.checker_ref_url = 'http://localhost:8010/static/site_for_checker/event_not_found.html'
        self.checker.save()
        
        scheduler_rt = SchedulerRuntime()
        scheduler_rt.save()
        
        self.event = Event(title='Event 1', event_website=self.event_website,
            description='Event 1 description', 
            url='http://localhost:8010/static/site_for_checker/event1.html',
            checker_runtime=scheduler_rt)
        self.event.save()

Example 8

View license
    def extraSetUpJSONChecker(self):
        self.rpt_dp1.content_type = 'J'
        self.rpt_dp1.save()
        
        self.checker = Checker()
        self.checker.scraped_obj_attr = self.soa_url
        self.checker.scraper = self.scraper
        self.checker.checker_type = 'X'
        self.checker.checker_x_path = 'event_not_found'
        self.checker.checker_x_path_result = 'Event not found!'
        self.checker.checker_ref_url = 'http://localhost:8010/static/site_with_json_content_type/event_not_found.json'
        self.checker.save()
        
        scheduler_rt = SchedulerRuntime()
        scheduler_rt.save()
        
        self.event = Event(title='Event 1', event_website=self.event_website,
            description='Event 1 description', 
            url='http://localhost:8010/static/site_with_json_content_type/event_not_found.json',
            checker_runtime=scheduler_rt)
        self.event.save()

Example 9

View license
    def test_double_standard_id_field(self):
        checker_rt = SchedulerRuntime()
        checker_rt.save()
        event = Event(title='Event 1', event_website=self.event_website,
            description='Event 1 description',
            url='http://localhost:8010/static/site_generic/event5.html',
            checker_runtime=checker_rt)
        event.save()
        event = Event(title='Event 2', event_website=self.event_website,
            description='Event 1 description',
            url='http://localhost:8010/static/site_generic/event6.html',
            checker_runtime=checker_rt)
        event.save()
        event = Event(title='Event 1', event_website=self.event_website,
            description='Event 2 description',
            url='http://localhost:8010/static/site_generic/event7.html',
            checker_runtime=checker_rt)
        event.save()
        self.soa_url.id_field = False
        self.soa_url.save()
        self.soa_title.id_field = True
        self.soa_title.save()
        self.soa_desc.id_field = True
        self.soa_desc.save()
        self.run_event_spider(1)
        
        self.assertEqual(len(Event.objects.all()), 6)
        self.assertEqual(Event.objects.filter(description='Event 1 description').count(), 2)