예제 #1
0
파일: tests.py 프로젝트: peisam/zjobs
    def test_find_all(self):
        self.blocked_contact.save()
        another_blocked_contact = BlockedContact("99999999", u"中介")
        another_blocked_contact.save()

        records = BlockedContact.findall()
        print "BlockedContacts", records
        self.assertEqual(2, len(records))
예제 #2
0
파일: tests.py 프로젝트: noushadali/zjobs
    def test_find_all(self):
        self.blocked_contact.save()
        another_blocked_contact = BlockedContact('99999999', u'中介')
        another_blocked_contact.save()

        records = BlockedContact.findall()
        print 'BlockedContacts', records
        self.assertEqual(2, len(records))
예제 #3
0
파일: tests.py 프로젝트: noushadali/zjobs
    def test_find_with_pagination(self):
        for i in range(0, 20):
            BlockedContact('%d' % i, '').save()

        records = BlockedContact.find_with_pagination(page_request={'page_no': 2, 'size': 10})

        print 'items', records
        self.assertEqual(10, len(records))
예제 #4
0
    def should_load_details(self, job_item):
        if JobItem.is_exists(job_item):
            logger.info(
                '[%s] skipping loading details as job already exists. job_title: %s'
                % (self.name, job_item.job_title))
            return False
        if JobItem.is_older_required(job_item):
            logger.info(
                '[%s] skipping loading details as job is older than %s days. job_title: %s'
                % (self.name, str(config.HOUSEKEEPING_RECORD_ORDLER_THAN),
                   job_item.job_title))
            return False

        if BlockedContact.is_contact_blocked(job_item.contact):
            logger.info(
                '[%s] skipping loading details as job contact is blocked. contact: %s'
                % (self.name, job_item.contact))
            return False

        if RejectionPattern.should_be_rejected(job_item.job_title):
            logger.info(
                '[%s] skipping loading details as job matches rejection pattern. job_title: %s'
                % (self.name, job_item.job_title))
            return False

        return True
예제 #5
0
파일: tests.py 프로젝트: peisam/zjobs
    def test_find_with_pagination(self):
        for i in range(0, 20):
            BlockedContact("%d" % i, "").save()

        records = BlockedContact.find_with_pagination(page_request={"page_no": 2, "size": 10})

        print "items", records
        self.assertEqual(10, len(records))
예제 #6
0
파일: base.py 프로젝트: dolphin93/zjobs
    def should_load_details(self, job_item):
        if JobItem.is_exists(job_item):
            logger.info('[%s] skipping loading details as job already exists. job_title: %s' % (self.name, job_item.job_title))
            return False
        if JobItem.is_older_required(job_item):
            logger.info('[%s] skipping loading details as job is older than %s days. job_title: %s' % (self.name, str(config.HOUSEKEEPING_RECORD_ORDLER_THAN), job_item.job_title))
            return False

        if BlockedContact.is_contact_blocked(job_item.contact):
            logger.info('[%s] skipping loading details as job contact is blocked. contact: %s' % (self.name, job_item.contact))
            return False

        if RejectionPattern.should_be_rejected(job_item.job_title):
            logger.info('[%s] skipping loading details as job matches rejection pattern. job_title: %s' % (self.name, job_item.job_title))
            return False

        return True
예제 #7
0
파일: tests.py 프로젝트: noushadali/zjobs
    def test_remove_blocked_records(self):
        for i in range(0, 20):
            job_item = JobItem()
            job_item.job_title=u'人员_%d' % i
            job_item.contact = str(random.randint(90000000, 99999999))
            job_item.save()

            # mark the contact as blocked
            BlockedContact(job_item.contact, u'人员').save()

        # run the remove action
        JobItem.remove_blocked_records()

        conn = self.connect_db()
        try:
            c = conn.cursor()
            c.execute('SELECT COUNT(*) FROM ' + JobItem.table_name)
            self.assertEqual(c.fetchone()[0], 0, 'Count of job items should be 0')
        except:
            pass
        finally:
            conn.close()
예제 #8
0
    def process_item(self, item, spider):
        # check by contact
        if BlockedContact.is_contact_blocked(item.contact):
            raise DropItem('Job is posted by blocked contact. Removing...')

        return item
예제 #9
0
파일: tests.py 프로젝트: noushadali/zjobs
 def test_find(self):
     self.blocked_contact.save()
     result = BlockedContact.find(self.blocked_contact)
     self.assertEqual(self.blocked_contact.contact, result.contact, 'Item found should be the same as saved')
예제 #10
0
파일: tests.py 프로젝트: noushadali/zjobs
 def setUp(self):
     self.clean_db()
     self.blocked_contact = BlockedContact('8888888', u'中介')
예제 #11
0
파일: tests.py 프로젝트: peisam/zjobs
 def test_find(self):
     self.blocked_contact.save()
     result = BlockedContact.find(self.blocked_contact)
     self.assertEqual(self.blocked_contact.contact, result.contact, "Item found should be the same as saved")
예제 #12
0
파일: tests.py 프로젝트: peisam/zjobs
 def test_is_contact_blocked(self):
     self.blocked_contact.save()
     self.assertTrue(BlockedContact.is_contact_blocked(self.blocked_contact.contact), "Contact should been blocked")
예제 #13
0
파일: tests.py 프로젝트: noushadali/zjobs
 def test_is_contact_blocked(self):
     self.blocked_contact.save()
     self.assertTrue(BlockedContact.is_contact_blocked(self.blocked_contact.contact), 'Contact should been blocked')
예제 #14
0
파일: tests.py 프로젝트: peisam/zjobs
 def setUp(self):
     self.clean_db()
     self.blocked_contact = BlockedContact("8888888", u"中介")
예제 #15
0
파일: tests.py 프로젝트: peisam/zjobs
class BlockedContactTest(BaseTestCase):
    def setUp(self):
        self.clean_db()
        self.blocked_contact = BlockedContact("8888888", u"中介")

    def tearDown(self):
        pass

    def test_save(self):
        self.blocked_contact.save()
        conn = self.connect_db()
        try:
            c = conn.cursor()
            c.execute("SELECT COUNT(*) FROM " + BlockedContact.table_name)
            self.assertEqual(c.fetchone()[0], 1, "Count of blocked contacts should be 1")
        except:
            pass
        finally:
            conn.close()

    def test_find_all(self):
        self.blocked_contact.save()
        another_blocked_contact = BlockedContact("99999999", u"中介")
        another_blocked_contact.save()

        records = BlockedContact.findall()
        print "BlockedContacts", records
        self.assertEqual(2, len(records))

    def test_find(self):
        self.blocked_contact.save()
        result = BlockedContact.find(self.blocked_contact)
        self.assertEqual(self.blocked_contact.contact, result.contact, "Item found should be the same as saved")

    def test_remove(self):
        self.blocked_contact.save()
        self.blocked_contact.remove()
        conn = self.connect_db()
        try:
            c = conn.cursor()
            c.execute("SELECT COUNT(*) FROM " + BlockedContact.table_name)
            self.assertEqual(c.fetchone()[0], 0, "Count of blocked contacts should be 0 after removing")
        except:
            pass
        finally:
            conn.close()

    def test_is_contact_blocked(self):
        self.blocked_contact.save()
        self.assertTrue(BlockedContact.is_contact_blocked(self.blocked_contact.contact), "Contact should been blocked")

    def test_find_with_pagination(self):
        for i in range(0, 20):
            BlockedContact("%d" % i, "").save()

        records = BlockedContact.find_with_pagination(page_request={"page_no": 2, "size": 10})

        print "items", records
        self.assertEqual(10, len(records))
예제 #16
0
파일: tests.py 프로젝트: noushadali/zjobs
class BlockedContactTest(BaseTestCase):
    def setUp(self):
        self.clean_db()
        self.blocked_contact = BlockedContact('8888888', u'中介')

    def tearDown(self):
        pass

    def test_save(self):
        self.blocked_contact.save()
        conn = self.connect_db()
        try:
            c = conn.cursor()
            c.execute('SELECT COUNT(*) FROM ' + BlockedContact.table_name)
            self.assertEqual(c.fetchone()[0], 1, 'Count of blocked contacts should be 1')
        except:
            pass
        finally:
            conn.close()

    def test_find_all(self):
        self.blocked_contact.save()
        another_blocked_contact = BlockedContact('99999999', u'中介')
        another_blocked_contact.save()

        records = BlockedContact.findall()
        print 'BlockedContacts', records
        self.assertEqual(2, len(records))

    def test_find(self):
        self.blocked_contact.save()
        result = BlockedContact.find(self.blocked_contact)
        self.assertEqual(self.blocked_contact.contact, result.contact, 'Item found should be the same as saved')


    def test_remove(self):
        self.blocked_contact.save()
        self.blocked_contact.remove()
        conn = self.connect_db()
        try:
            c = conn.cursor()
            c.execute('SELECT COUNT(*) FROM ' + BlockedContact.table_name)
            self.assertEqual(c.fetchone()[0], 0, 'Count of blocked contacts should be 0 after removing')
        except:
            pass
        finally:
            conn.close()

    def test_is_contact_blocked(self):
        self.blocked_contact.save()
        self.assertTrue(BlockedContact.is_contact_blocked(self.blocked_contact.contact), 'Contact should been blocked')

    def test_find_with_pagination(self):
        for i in range(0, 20):
            BlockedContact('%d' % i, '').save()

        records = BlockedContact.find_with_pagination(page_request={'page_no': 2, 'size': 10})

        print 'items', records
        self.assertEqual(10, len(records))
예제 #17
0
    def process_item(self, item, spider):
        # check by contact
        if BlockedContact.is_contact_blocked(item.contact):
            raise DropItem('Job is posted by blocked contact. Removing...')

        return item