text: # -*- coding: utf-8 -*-
  
  #  Licensed under the Apache License, Version 2.0 (the "License"); you may
  #  not use this file except in compliance with the License. You may obtain
  #  a copy of the License at
  #
  #       https://www.apache.org/licenses/LICENSE-2.0
  #
  #  Unless required by applicable law or agreed to in writing, software
  #  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  #  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  #  License for the specific language governing permissions and limitations
  #  under the License.
  
  from __future__ import unicode_literals, absolute_import
  
  import json
  import unittest
  
  import responses
  
  from linebot import (
      LineBotApi
  )
  from linebot.models import (
      LocationSendMessage
  )
  
  
  class TestLineBotApi(unittest.TestCase):
      def setUp(self):
          self.tested = LineBotApi('d42b9b5dc4df7ad44e9bddd5ee915fc7')
  
          self.location_message = LocationSendMessage(
              title='my location',
              address='Tokyo',
              latitude=35.65910807942215,
              longitude=139.70372892916203
          )
  
          self.message = [{
              "type": "location",
              "title": "my location",
              "address": "Tokyo",
              "latitude": 35.65910807942215,
              "longitude": 139.70372892916203
          }]
  
      @responses.activate
      def test_push_location_message(self):
          responses.add(
              responses.POST,
              LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/message/push',
              json={}, status=200
          )
  
          self.tested.push_message('to', self.location_message)
  
          request = responses.calls[0].request
          self.assertEqual(request.method, 'POST')
          self.assertEqual(
              request.url,
              LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/message/push')
          self.assertEqual(
              json.loads(request.body),
              {
                  "to": "to",
                  "messages": self.message
              }
          )
  
      @responses.activate
      def test_reply_location_message(self):
          responses.add(
              responses.POST,
              LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/message/reply',
              json={}, status=200
          )
  
          self.tested.reply_message('replyToken', self.location_message)
  
          request = responses.calls[0].request
          self.assertEqual(request.method, 'POST')
          self.assertEqual(
              request.url,
              LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/message/reply')
          self.assertEqual(
              json.loads(request.body),
              {
                  "replyToken": "replyToken",
                  "messages": self.message
              }
          )
  
      @responses.activate
      def test_multicast_location_message(self):
          responses.add(
              responses.POST,
              LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/message/multicast',
              json={}, status=200
          )
  
          self.tested.multicast(['to1', 'to2'], self.location_message)
  
          request = responses.calls[0].request
          self.assertEqual(request.method, 'POST')
          self.assertEqual(
              request.url,
              LineBotApi.DEFAULT_API_ENDPOINT + '/v2/bot/message/multicast')
          self.assertEqual(
              json.loads(request.body),
              {
                  "to": ['to1', 'to2'],
                  "messages": self.message
              }
          )
  
  
  if __name__ == '__main__':
      unittest.main()
  