# -*- coding: utf-8 -*-

# Copyright (C) 2015-2016 Avencall
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

import unittest

from mock import Mock, sentinel

from xivo_bus.marshaler import Marshaler
from xivo_bus.publisher import Publisher
from hamcrest import assert_that
from hamcrest import calling
from hamcrest import equal_to
from hamcrest import raises
from ..transfer import CreateTransferEvent, AnswerTransferEvent, CancelTransferEvent, CompleteTransferEvent, \
    AbandonTransferEvent, RefreshCurrentCall, CurrentCallSendMessage, EndTransferEvent

from unittest import TestCase


class TestTransfer(TestCase):
    def setUp(self):
        pass

    def test_CreateTransferEvent(self):
        self.name = 'transfer_created'
        self.routing_key = 'calls.transfer.created'
        a = CreateTransferEvent
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

    def test_AnswerTransferEvent(self):
        self.name = 'transfer_answered'
        self.routing_key = 'calls.transfer.edited'
        a = AnswerTransferEvent
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

    def test_CancelTransferEvent(self):
        self.name = 'transfer_cancelled'
        self.routing_key = 'calls.transfer.edited'
        a = CancelTransferEvent
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

    def test_CompleteTransferEvent(self):
        self.name = 'transfer_completed'
        self.routing_key = 'calls.transfer.edited'
        a = CompleteTransferEvent
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

    def test_AbandonTransferEvent(self):
        self.name = 'transfer_abandoned'
        self.routing_key = 'calls.transfer.edited'
        a = AbandonTransferEvent
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

    def test_RefreshCurrentCall(self):
        self.name = 'transfer_current_call_refresh'
        self.routing_key = 'calls.transfer.edited'
        a = RefreshCurrentCall
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

    def test_CurrentCallSendMessage(self):
        self.name = 'transfer_current_call_send_message'
        self.routing_key = 'calls.transfer.edited'
        a = CurrentCallSendMessage
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)


    def test_EndTransferEvent(self):
        self.name = 'transfer_ended'
        self.routing_key = 'calls.transfer.deleted'
        a = EndTransferEvent
        self.assertEqual(a.name, self.name)
        self.assertEqual(a.routing_key, self.routing_key)

