Exemple #1
0
    def test_cancel_collect(self):
        email = '*****@*****.**'
        photo_url = 'test_url'
        tag = u'tag1、tag2'
        dbControl.save_photo_and_tag(photo_url=photo_url, description='no',
                tag=tag, person_id_list=[], permission='public', owner=email)
        photo_id= Photo.objects.get(photo_url=photo_url).id
        dbControl.add_collect(email, photo_id)
        collected_times = Photo.objects.get(id=photo_id).collected_times
        self.assertEqual(collected_times, 1)

        dbControl.cancel_collect(email=email, photo_id=photo_id)
        collected_times = Photo.objects.get(id=photo_id).collected_times
        self.assertEqual(collected_times, 0)
Exemple #2
0
def upload_photo(photo_file, description, tag, permission, owner):
    # upload photo
    photo_url = storage.obj_upload(photo_file, tag)
    thumbnail_url = get_thumbnail_url(
        photo_url, size='c_fit,w_750')
    # add face to faceset
    person_id_list = faceControl.add_faces(
            method='url', url_or_path=thumbnail_url)
    # save photo and tags
    dbControl.save_photo_and_tag(
        photo_url, description, tag, person_id_list, permission, owner)
    # save info
    photo_info = dbControl.get_photo_info(photo_url, method='url')
    return photo_info
Exemple #3
0
    def test_add_collect(self):
        import pdb
        pdb.set_trace()
        email = '*****@*****.**'
        photo_url = 'test_url'
        tag = u'tag1、tag2'
        dbControl.save_photo_and_tag(photo_url=photo_url, description='no',
                tag=tag, person_id_list=[], permission='public', owner=email)
        photo_id= Photo.objects.get(photo_url=photo_url).id
        dbControl.add_collect(email, photo_id)
        collected_times = Photo.objects.get(id=photo_id).collected_times

        self.assertTrue(Collect.objects.get(
                email=email, photo_id=photo_id))
        self.assertEqual(collected_times, 1)
        self.assertTrue(Interest.objects.get(email=email, interested_tag='tag2'))