from unittest import TestCase

from StubHubInventoryMechanizer.ticket import Ticket


__author__ = 'chorton'


class TestTicketOperators(TestCase):
    def test___eq__(self):
        a = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], 1234, 'create')
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], None, None)
        self.assertEqual(a, b)

    def test___ne__(self):
        a = Ticket('321', '12', ['1', '2', '3'], 120.0, ['10', '23', '34'], 1234, 'create')
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], None, None)
        self.assertNotEqual(a, b)

    def test___gt__(self):
        a = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], None, None)
        b = Ticket('321', '12', ['1', '2'], 120.0, ['12', '23', '34'], 1234, 'create')
        self.assertGreater(a, b)

    def test___lt__(self):
        a = Ticket('321', '12', ['1', '2'], 120.0, ['12', '23', '34'], None, None)
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], 1234, 'create')
        self.assertLess(a, b)


class TestTicket(TestCase):
    def test_seat_difference_description_bottom(self):
        a = Ticket('321', '12', ['1', '2'], 120.0, ['12', '23', '34'], None, None)
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], 1234, 'create')
        result = a.seat_difference_description(b)
        self.assertEqual(result, 'bottom')

    def test_seat_difference_description_top(self):
        a = Ticket('321', '12', ['2', '3'], 120.0, ['12', '23', '34'], None, None)
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], 1234, 'create')
        result = a.seat_difference_description(b)
        self.assertEqual(result, 'top')

    def test_seat_difference_description_middle(self):
        a = Ticket('321', '12', ['1', '3'], 120.0, ['12', '23', '34'], None, None)
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], 1234, 'create')
        result = a.seat_difference_description(b)
        self.assertEqual(result, 'middle')

    def test_get_ticket_actions(self):
        a = Ticket('321', '12', ['1', '2'], 120.0, ['12', '23', '34'], None, None)
        b = Ticket('321', '12', ['1', '2', '3'], 120.0, ['12', '23', '34'], 1234, 'create')
        result = a.get_ticket_actions(b)
        self.assertEqual(result.action['action'], 'updatequantity')
