# Path: arangodb/orm/fields.py
# class ChoiceField(ModelField):
#     """
#     """
# 
#     def __init__(self, choices, multiple=False, **kwargs):
#         """
#         """
# 
#         super(ChoiceField, self).__init__(**kwargs)
# 
#         self.choices = choices
# 
#         # If null is allowed, default value is None
#         if self.null and not self.default:
#             self.choice_value = None
#         else:
#             # If default value was set
#             if self.default:
#                 self.choice_value = self.default
#             else:
#                 self.choice_value = ''
# 
#     def dumps(self):
#         """
#         """
# 
#         return self.choice_value
# 
#     def loads(self, string_val):
#         """
#         """
# 
#         self.choice_value = string_val
# 
#     def validate(self):
#         """
#         """
# 
#         has_match = False
# 
#         for choice_pair in self.choices:
#             if choice_pair[0] == self.choice_value:
#                 has_match = True
#                 break
# 
#         if not has_match:
#             raise ChoiceField.WrongInputTypeException()
# 
#         if self.choice_value is None and self.null is False:
#             raise ChoiceField.NotNullableFieldException()
# 
#     def set(self, *args, **kwargs):
#         """
#         """
# 
#         if len(args) is 1:
#             choice_value = args[0]
#             self.choice_value = choice_value
# 
#             self.validate()
# 
#     def get(self):
#         """
#         """
# 
#         return self.choice_value
# 
#     def __eq__(self, other):
#         """
#         """
# 
#         if super(ChoiceField, self).__eq__(other):
#             return self.choice_value == other.choice_value
#         else:
#             return False
# 
#     def __getattribute__(self, item):
#         """
#         """
# 
#         if item == 'flatchoices':
#             return object.__getattribute__(self, 'choices')
#         else:
#             return super(ChoiceField, self).__getattribute__(item)


import unittest
from arangodb.orm.fields import ChoiceField


class ChoiceFieldTestCase(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_field_validation(self):


# Path: arangodb/orm/fields.py
# class ChoiceField(ModelField):
#     """
#     """
# 
#     def __init__(self, choices, multiple=False, **kwargs):
#         """
#         """
# 
#         super(ChoiceField, self).__init__(**kwargs)
# 
#         self.choices = choices
# 
#         # If null is allowed, default value is None
#         if self.null and not self.default:
#             self.choice_value = None
#         else:
#             # If default value was set
#             if self.default:
#                 self.choice_value = self.default
#             else:
#                 self.choice_value = ''
# 
#     def dumps(self):
#         """
#         """
# 
#         return self.choice_value
# 
#     def loads(self, string_val):
#         """
#         """
# 
#         self.choice_value = string_val
# 
#     def validate(self):
#         """
#         """
# 
#         has_match = False
# 
#         for choice_pair in self.choices:
#             if choice_pair[0] == self.choice_value:
#                 has_match = True
#                 break
# 
#         if not has_match:
#             raise ChoiceField.WrongInputTypeException()
# 
#         if self.choice_value is None and self.null is False:
#             raise ChoiceField.NotNullableFieldException()
# 
#     def set(self, *args, **kwargs):
#         """
#         """
# 
#         if len(args) is 1:
#             choice_value = args[0]
#             self.choice_value = choice_value
# 
#             self.validate()
# 
#     def get(self):
#         """
#         """
# 
#         return self.choice_value
# 
#     def __eq__(self, other):
#         """
#         """
# 
#         if super(ChoiceField, self).__eq__(other):
#             return self.choice_value == other.choice_value
#         else:
#             return False
# 
#     def __getattribute__(self, item):
#         """
#         """
# 
#         if item == 'flatchoices':
#             return object.__getattribute__(self, 'choices')
#         else:
#             return super(ChoiceField, self).__getattribute__(item)


# Path: arangodb/tests/orm/fields/choice.py
import unittest
from arangodb.orm.fields import ChoiceField



class ChoiceFieldTestCase(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_field_validation(self):


        choice = ChoiceField(choices=[