示例#1
0
    def test_update_entities(self):
        c = EntitiesCrawler()
        with self.assertRaises(ValidationError):
            c.update(0, 1)

        models.Country.objects.create(name='Portugal')

        mods = c.update(0, 1)
        self.assertEqual(2, mods['added'])
    def test_update_entities(self):
        c = EntitiesCrawler()
        with self.assertRaises(ValidationError):
            c.update(0, 1)

        models.Country.objects.create(name='Portugal')

        mods = c.update(0, 1)
        self.assertEqual(2, mods['added'])

        # call update again should not make any change
        mods = c.update(0, 1)
        self.assertEqual(0, mods['added'])
        self.assertEqual(0, mods['deleted'])
        self.assertEqual(0, mods['updated'])
    def test_update_entities(self):
        c = EntitiesCrawler()
        with self.assertRaises(ValidationError):
            c.update(0, 1)

        models.Country.objects.create(name='Portugal')

        mods = c.update(0, 1)
        self.assertEqual(2, mods['added'])

        # call update again should not make any change
        mods = c.update(0, 1)
        self.assertEqual(0, mods['added'])
        self.assertEqual(0, mods['deleted'])
        self.assertEqual(0, mods['updated'])
示例#4
0
    def handle(self, **options):
        if options['static']:
            if options['bootstrap'] or not ProcedureType.objects.exists():
                ContractsStaticDataCrawler().retrieve_and_save_all()

        if options['categories']:
            if options['bootstrap'] or not Category.objects.exists():
                build_categories()

        if options['entities']:
            crawler = EntitiesCrawler()
            if options['bootstrap']:
                crawler.update(0)
            else:
                crawler.update(-2000)

        if options['contracts']:
            crawler = ContractsCrawler()
            if options['bootstrap']:
                crawler.update(0)
            else:
                crawler.update(-2000)

        if options['tenders']:
            crawler = TendersCrawler()
            if options['bootstrap']:
                crawler.update(0)
            else:
                crawler.update(-2000)
    def handle(self, **options):
        if options['static']:
            if options['bootstrap'] or not ProcedureType.objects.exists():
                ContractsStaticDataCrawler().retrieve_and_save_all()

        if options['categories']:
            if options['bootstrap'] or not Category.objects.exists():
                build_categories()

        if options['entities']:
            crawler = EntitiesCrawler()
            if options['bootstrap']:
                crawler.update(0)
            else:
                crawler.update(-2000)

        if options['contracts']:
            crawler = ContractsCrawler()
            if options['bootstrap']:
                crawler.update(0)
            else:
                crawler.update(-2000)

        if options['tenders']:
            crawler = TendersCrawler()
            if options['bootstrap']:
                crawler.update(0)
            else:
                crawler.update(-2000)