Exemplo n.º 1
0
    def test_RecruitInfo(self):
        idx = '2'
        info = RecruitInfo(idx)
        self.assertEqual(info.json, info.obj._data)
        # repr(info) will be the dumpe of json
        self.assertEqual(repr(info), json.dumps(info.obj._data))

        url = 'http://www.saramin.co.kr/zf_user/recruit/recruit-view?idx=2'
        info2 = RecruitInfo(url)
        self.assertEqual(info2.json, info2.obj._data)
        #self.assertEqual(info2.json, {'rating': None, 'full': None, 'idx': u'2', 'url': None, 'company': None, 'summary': None, 'dday': None, 'memo': u'The idx is 2'})

        mjson = {"url": 'http://www.saramin.co.kr/zf_user/recruit/recruit-view?idx=18',
                "rating": '3',
                "memo": "this is memo"}
        
        info3 = RecruitInfo()
        info3.getFromJson(mjson)
        info3.save()
        #self.assertEqual(info3.json, {'rating': '3', 'full': None, 'idx': '18', 'url': 'http://www.saramin.co.kr/zf_user/recruit/recruit-view?idx=18', 'memo': 'this is memo', 'summary': None, 'dday': None, 'company': None})

        # Check the save
        info18 = RecruitInfo('18')
        self.assertEqual(info18.memo, 'this is memo')
        # Fixme: It don't work. infoc will return 'this is memo'.
        info18.memo = "aaa"
        info18.save()
        self.assertEqual(info18.memo, 'aaa')


        infoc = RecruitInfo('18')
        self.assertEqual(infoc.memo, 'aaa')


        mjson2 = {"url": 'http://www.saramin.co.kr/zf_user/recruit/recruit-view?idx=18',
                "rating": '3',
                "memo": "memo2"}

        infoa = RecruitInfo()
        infoa.getFromJson(mjson2)
        infoa.save()

        infoa2 = RecruitInfo('18')
        self.assertEqual(infoa2.memo, 'memo2')

        info2.aac = "aac"
        self.assertEqual(info2.aac, 'aac')

        # getFromObject method
        rec_obj = Recruit.objects(idx='18')[0]
        infoa3 = RecruitInfo()
        infoa3.getFromObject(rec_obj)
        self.assertEqual(infoa2.memo, 'memo2')
Exemplo n.º 2
0
    def document2fullcalendar(self):
        today = datetime.today()

        rec = Recruit()
        rec.idx = '8888'
        rec.url = 'http://google.com'
        rec.title = u'몰라'
        rec.end = datetime.today()
        rec.save()

        rec_info = RecruitInfo('8888')
Exemplo n.º 3
0
    def documents2jsondump(self):
        today = datetime.today()
        yesterday = today + timedelta(-1)
        recs = Recruit.objects
        recs = Recruit.objects(end__gt = yesterday)

        result = []
        rec_temp = None
        for rec in recs:
            rec_temp = RecruitInfo()
            rec_temp.getFromObject(rec)
            result.append(rec_temp._repr())

        self.assertEqual(documents2jsondump(recs), json.dumps(result))
Exemplo n.º 4
0
def removeDummy():

    Recruit.drop_collection()
    Company.drop_collection()
Exemplo n.º 5
0
def createDummy():

    connect(config.db_name_test)

    today = datetime.today()

    company1 = Company()
    company1.idx = '93920'
    company1.name = '달수네'
    company1.save()

    company2 = Company()
    company2.idx = '99910'
    company2.name = '말수네'
    company2.save()

    recruit1 = Recruit()
    recruit1.idx = '1'
    recruit1.memo = 'The idx is 1'
    recruit1.end = today + timedelta(-3)
    recruit1.save()

    recruit2 = Recruit()
    recruit2.idx = '2'
    recruit2.memo = 'The idx is 2'
    recruit2.end = today + timedelta(0)
    recruit2.save()

    recruit3 = Recruit()
    recruit3.idx = '3'
    recruit3.memo = 'The idx is 3'
    recruit3.end = today + timedelta(3)
    recruit3.save()

    recruit4 = Recruit()
    recruit4.idx = '4'
    recruit4.title = "permanent recruit"
    recruit4.memo = 'The idx is 4'
    recruit4.end = None
    recruit4.save()
Exemplo n.º 6
0
 def _recruits(self):
     today = datetime.today()
     yesterday = today + timedelta(-1)
     recs = Recruit.objects
     recs = Recruit.objects(end__gt = yesterday)
Exemplo n.º 7
0
 def tearDownClass(cls):
     Recruit.drop_collection()
     Company.drop_collection()