# Path: WeCron/remind/tests/test_serializers.py
# @urlmatch(netloc=r'(.*\.)?api\.weixin\.qq\.com$', path='.*qrcode/create')
# def create_qrcode_mock(url, request):
#     content = {
#         'ticket': 'gQH47joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL2taZ2Z3TVRtNzJXV1Brb3ZhYmJJAAIEZ23sUwMEmm3sUw==',
#         'expires_in': 30,
#         'url': 'http:\/\/weixin.qq.com\/q\/kZgfwMTm72WWPkovabbI',
#     }
#     headers = {
#         'Content-Type': 'application/json'
#     }
#     return response(200, content, headers, request=request)


from django.test import TestCase
from django.utils import timezone
from httmock import urlmatch, response, with_httmock
from common.tests import access_token_mock
from .test_serializers import create_qrcode_mock
from remind.models import Remind
from wechat_user.models import WechatUser
from remind.share_post import draw_post, TPL_IMAGE_PATH
# coding: utf-8
from __future__ import unicode_literals, absolute_import



DISPLAY_POST = True


@urlmatch(netloc=r'(.*\.)?mp\.weixin\.qq\.com$', path='.*showqrcode')
def get_qr_image_mock(url, request):
    content = open(TPL_IMAGE_PATH, 'rb').read()
    headers = {
        'Content-Type': 'image/png'
    }
    return response(200, content, request=request)


class SharePostTestCase(TestCase):

    def setUp(self):
        self.user = WechatUser(openid='miao', nickname='miaomiao', subscribe=True, last_login=timezone.now())
        self.user.save()


# Path: WeCron/remind/tests/test_serializers.py
# @urlmatch(netloc=r'(.*\.)?api\.weixin\.qq\.com$', path='.*qrcode/create')
# def create_qrcode_mock(url, request):
#     content = {
#         'ticket': 'gQH47joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL2taZ2Z3TVRtNzJXV1Brb3ZhYmJJAAIEZ23sUwMEmm3sUw==',
#         'expires_in': 30,
#         'url': 'http:\/\/weixin.qq.com\/q\/kZgfwMTm72WWPkovabbI',
#     }
#     headers = {
#         'Content-Type': 'application/json'
#     }
#     return response(200, content, headers, request=request)


# Path: WeCron/remind/tests/test_share_post.py
from django.test import TestCase
from django.utils import timezone
from httmock import urlmatch, response, with_httmock
from common.tests import access_token_mock
from .test_serializers import create_qrcode_mock
from remind.models import Remind
from wechat_user.models import WechatUser
from remind.share_post import draw_post, TPL_IMAGE_PATH

# coding: utf-8
from __future__ import unicode_literals, absolute_import



DISPLAY_POST = True


@urlmatch(netloc=r'(.*\.)?mp\.weixin\.qq\.com$', path='.*showqrcode')
def get_qr_image_mock(url, request):
    content = open(TPL_IMAGE_PATH, 'rb').read()
    headers = {
        'Content-Type': 'image/png'
    }
    return response(200, content, request=request)


class SharePostTestCase(TestCase):

    def setUp(self):
        self.user = WechatUser(openid='miao', nickname='miaomiao', subscribe=True, last_login=timezone.now())
        self.user.save()


    @with_httmock(access_token_mock, create_qrcode_mock, get_qr_image_mock)