# Path: fixtest/base/message.py
# class BasicMessage(collections.MutableMapping):
#     """ A BasicMessage is just a collection of (ID, VALUE) pairs.
# 
#         All IDs are converted into strings, this allows users of the
#         BasicMessage to class to use integers or strings as keys.
#         e.g. message[35] == message['35']
# 
#         If you iterate through the BasicMessage, the items will be
#         returned in the order they were added.  This is important
#         because the order of the fields is important to FIX.
#     """
#     def __init__(self, **kwargs):
#         """ Initialization
# 
#             Args:
#                 source: copy over the fields from the source and
#                     merge with this.  This can be a list of (ID, VALUE)
#                     tuples or a BasicMessage().
#         """
#         self.store = collections.OrderedDict()
# 
#         if 'source' in kwargs:
#             self.update(kwargs['source'])
# 
#     def __getitem__(self, key):
#         return self.store[self.__keytransform__(key)]
# 
#     def __setitem__(self, key, value):
#         self.store[self.__keytransform__(key)] = value
# 
#     def __delitem__(self, key):
#         del self.store[self.__keytransform__(key)]
# 
#     def __iter__(self):
#         return iter(self.store)
# 
#     def __len__(self):
#         return len(self.store)
# 
#     def __keytransform__(self, key):
#         """ Override this to enforce the type of key expected.
#         """
#         # pylint: disable=no-self-use
#         return str(key)


import collections
import unittest
from fixtest.base.message import BasicMessage
    def test_from_list(self):
        mess = BasicMessage(source=[(23, 2323), (33, 3333), (11, 1111)])
        self.assertEquals(3, len(mess))

        items = [(k, v) for k, v in mess.items()]
        self.assertEquals('23', items[0][0])
        self.assertEquals(2323, items[0][1])
        self.assertEquals('33', items[1][0])
        self.assertEquals(3333, items[1][1])
        self.assertEquals('11', items[2][0])
        self.assertEquals(1111, items[2][1])

    def test_from_ordereddict(self):
        new_dict = collections.OrderedDict()
        new_dict[22] = 99
        new_dict[21] = 101
        new_dict[20] = 2020

        mess = BasicMessage(source=new_dict)
        self.assertEquals(3, len(mess))

        items = [(k, v) for k, v in mess.items()]
        self.assertEquals('22', items[0][0])
        self.assertEquals(99, items[0][1])
        self.assertEquals('21', items[1][0])
        self.assertEquals(101, items[1][1])
        self.assertEquals('20', items[2][0])
        self.assertEquals(2020, items[2][1])

    def test_ordering(self):

# Path: fixtest/base/message.py
# class BasicMessage(collections.MutableMapping):
#     """ A BasicMessage is just a collection of (ID, VALUE) pairs.
# 
#         All IDs are converted into strings, this allows users of the
#         BasicMessage to class to use integers or strings as keys.
#         e.g. message[35] == message['35']
# 
#         If you iterate through the BasicMessage, the items will be
#         returned in the order they were added.  This is important
#         because the order of the fields is important to FIX.
#     """
#     def __init__(self, **kwargs):
#         """ Initialization
# 
#             Args:
#                 source: copy over the fields from the source and
#                     merge with this.  This can be a list of (ID, VALUE)
#                     tuples or a BasicMessage().
#         """
#         self.store = collections.OrderedDict()
# 
#         if 'source' in kwargs:
#             self.update(kwargs['source'])
# 
#     def __getitem__(self, key):
#         return self.store[self.__keytransform__(key)]
# 
#     def __setitem__(self, key, value):
#         self.store[self.__keytransform__(key)] = value
# 
#     def __delitem__(self, key):
#         del self.store[self.__keytransform__(key)]
# 
#     def __iter__(self):
#         return iter(self.store)
# 
#     def __len__(self):
#         return len(self.store)
# 
#     def __keytransform__(self, key):
#         """ Override this to enforce the type of key expected.
#         """
#         # pylint: disable=no-self-use
#         return str(key)


# Path: fixtest/tests/base_message_test.py
import collections
import unittest
from fixtest.base.message import BasicMessage

    def test_from_list(self):
        mess = BasicMessage(source=[(23, 2323), (33, 3333), (11, 1111)])
        self.assertEquals(3, len(mess))

        items = [(k, v) for k, v in mess.items()]
        self.assertEquals('23', items[0][0])
        self.assertEquals(2323, items[0][1])
        self.assertEquals('33', items[1][0])
        self.assertEquals(3333, items[1][1])
        self.assertEquals('11', items[2][0])
        self.assertEquals(1111, items[2][1])

    def test_from_ordereddict(self):
        new_dict = collections.OrderedDict()
        new_dict[22] = 99
        new_dict[21] = 101
        new_dict[20] = 2020

        mess = BasicMessage(source=new_dict)
        self.assertEquals(3, len(mess))

        items = [(k, v) for k, v in mess.items()]
        self.assertEquals('22', items[0][0])
        self.assertEquals(99, items[0][1])
        self.assertEquals('21', items[1][0])
        self.assertEquals(101, items[1][1])
        self.assertEquals('20', items[2][0])
        self.assertEquals(2020, items[2][1])

    def test_ordering(self):

        mess = BasicMessage()