Example #1
0
 def test_save_and_retreive_4square(self):
     if WORK_ENVIRONMENT: return
     test_data = '4ccffc63f6378cfaace1b1d6.4square'
     lp, is_created = LegacyPlace.get_or_create_smart(test_data)
     self.assertEqual(lp.uuid.split('.')[1], '4square')
     saved = LegacyPlace.objects.first()
     self.assertEqual(saved, lp)
     self.assertEqual(saved.id, lp.id)
     saved2 = LegacyPlace.get_from_json('{"uuid": "%s", "content": null}' % lp.uuid)
     self.assertEqual(saved2.content, lp.content)
     saved3 = LegacyPlace.get_from_json('{"uuid": null, "content": "%s"}' % lp.content)
     self.assertEqual(saved3, lp)
Example #2
0
    def setUp(self, json, timestamp=None, vd=None):

        # name 조회
        if is_valid_json_item('name', json):
            name = PlaceName.get_from_json(json['name'])
            if name:
                name.vd = vd
                self.names.append(name)

        # visit 조회
        if is_valid_json_item('visit', json):
            visit = Visit.get_from_json(json['visit'])
            if visit:
                visit.vd = vd
                self.visits.append(visit)

        # rating 조회
        if is_valid_json_item('rating', json):
            rating = Rating.get_from_json(json['rating'])
            if rating:
                rating.vd = vd
                self.ratings.append(rating)

        # lonLat 조회
        if is_valid_json_item('lonLat', json):
            point = Point.get_from_json(json['lonLat'])
            if point:
                point.vd = vd
                self.points.append(point)

        # phone 조회
        if is_valid_json_item('phone', json):
            phone = PhoneNumber.get_from_json(json['phone'])
            if phone:
                phone.vd = vd
                self.phone = phone

        # addr1 조회
        if is_valid_json_item('addr1', json):
            addr1 = Address.get_from_json(json['addr1'])
            if addr1:
                addr1.vd = vd
                self.addrs1.append(addr1)

        # addr2 조회
        if is_valid_json_item('addr2', json):
            addr2 = Address.get_from_json(json['addr2'])
            if addr2:
                addr2.vd = vd
                self.addrs2.append(addr2)

        # addr3 조회
        if is_valid_json_item('addr3', json):
            addr3 = Address.get_from_json(json['addr3'])
            if addr3:
                addr3.vd = vd
                self.addrs3.append(addr3)

        # lps 조회
        if is_valid_json_item('lps', json):
            for lp_json in json['lps']:
                if is_valid_json_item(None, json):
                    lp = LegacyPlace.get_from_json(lp_json)
                    if lp:
                        lp.vd = vd
                        self.lps.append(lp)

        # urls 조회
        if is_valid_json_item('urls', json):
            from url.models import Url
            for url_json in json['urls']:
                if is_valid_json_item(None, url_json):
                    url = Url.get_from_json(url_json)
                    if url:
                        url.vd = vd
                        self.urls.append(url)

        # notes 조회
        if is_valid_json_item('notes', json):
            for note_json in json['notes']:
                if is_valid_json_item(None, note_json):
                    note = PlaceNote.get_from_json(note_json)
                    if note:
                        note.timestamp = timestamp
                        note.vd = vd
                        self.notes.append(note)

        # images 조회
        if is_valid_json_item('images', json):
            for img_json in json['images']:
                if is_valid_json_item(None, img_json):
                    img = Image.get_from_json(img_json)
                    if img:
                        if 'note' in img_json and img_json['note']:
                            note = ImageNote.get_from_json(img_json['note'])
                            if note:
                                note.timestamp = timestamp
                                note.vd = vd
                                img.note = note
                        img.vd = vd
                        self.images.append(img)

        # place_id, uplace_uuid, iplace_uuid 조회
        if is_valid_json_item('place_id', json):
            self.place_id = json['place_id']
        if is_valid_json_item('uplace_uuid', json):
            self.uplace_uuid = json['uplace_uuid']
        if is_valid_json_item('iplace_uuid', json):
            self.iplace_uuid = json['iplace_uuid']