# Path: groundstation/objects/base_object_pb2.py
# class BaseObject(_message.Message):
#   __metaclass__ = _reflection.GeneratedProtocolMessageType
#   DESCRIPTOR = _BASEOBJECT
# 
#   # @@protoc_insertion_point(class_scope:BaseObject)
# 
# ROOT = 1
# 
# UPDATE = 2
# 
# UNSET = 0
# 
# Path: groundstation/objects/root_object_pb2.py
# class RootObject(_message.Message):
#   __metaclass__ = _reflection.GeneratedProtocolMessageType
#   DESCRIPTOR = _ROOTOBJECT
# 
#   # @@protoc_insertion_point(class_scope:RootObject)
# 
# Path: groundstation/objects/update_object_pb2.py
# class UpdateObject(_message.Message):
#   __metaclass__ = _reflection.GeneratedProtocolMessageType
#   DESCRIPTOR = _UPDATEOBJECT
# 
#   # @@protoc_insertion_point(class_scope:UpdateObject)


import unittest
import groundstation.objects.object_factory as object_factory
from groundstation.objects.base_object_pb2 import BaseObject, \
    ROOT as TYPE_ROOT, \
    UPDATE as TYPE_UPDATE, \
    UNSET as TYPE_UNSET
from groundstation.objects.root_object_pb2 import RootObject
from groundstation.objects.update_object_pb2 import UpdateObject
    root.protocol = "butts"
    if not weak:
        root.type = TYPE_ROOT
    return root


def new_update_object(weak, parents=[]):
    update = UpdateObject()
    update.parents.extend(parents)
    update.data = "butts"
    if not weak:
        update.type = TYPE_UPDATE
    return update


class TypeOfTestCase(unittest.TestCase):
    def test_strongly_typed_root(self):
        root_str = new_root_object(False).SerializeToString()
        self.assertEqual(object_factory.type_of(root_str), TYPE_ROOT)

    def test_weakly_typed_root(self):
        root_str = new_root_object(True).SerializeToString()
        self.assertEqual(object_factory.type_of(root_str), TYPE_UNSET)

    def test_strongly_typed_update(self):
        update_str = new_update_object(False).SerializeToString()
        self.assertEqual(object_factory.type_of(update_str), TYPE_UPDATE)

    def test_weakly_typed_update(self):
        update_str = new_update_object(True).SerializeToString()

# Path: groundstation/objects/base_object_pb2.py
# class BaseObject(_message.Message):
#   __metaclass__ = _reflection.GeneratedProtocolMessageType
#   DESCRIPTOR = _BASEOBJECT
# 
#   # @@protoc_insertion_point(class_scope:BaseObject)
# 
# ROOT = 1
# 
# UPDATE = 2
# 
# UNSET = 0
# 
# Path: groundstation/objects/root_object_pb2.py
# class RootObject(_message.Message):
#   __metaclass__ = _reflection.GeneratedProtocolMessageType
#   DESCRIPTOR = _ROOTOBJECT
# 
#   # @@protoc_insertion_point(class_scope:RootObject)
# 
# Path: groundstation/objects/update_object_pb2.py
# class UpdateObject(_message.Message):
#   __metaclass__ = _reflection.GeneratedProtocolMessageType
#   DESCRIPTOR = _UPDATEOBJECT
# 
#   # @@protoc_insertion_point(class_scope:UpdateObject)


# Path: test/test_object_discrimination.py
import unittest
import groundstation.objects.object_factory as object_factory
from groundstation.objects.base_object_pb2 import BaseObject, \
    ROOT as TYPE_ROOT, \
    UPDATE as TYPE_UPDATE, \
    UNSET as TYPE_UNSET
from groundstation.objects.root_object_pb2 import RootObject
from groundstation.objects.update_object_pb2 import UpdateObject

    root.protocol = "butts"
    if not weak:
        root.type = TYPE_ROOT
    return root


def new_update_object(weak, parents=[]):
    update = UpdateObject()
    update.parents.extend(parents)
    update.data = "butts"
    if not weak:
        update.type = TYPE_UPDATE
    return update


class TypeOfTestCase(unittest.TestCase):
    def test_strongly_typed_root(self):
        root_str = new_root_object(False).SerializeToString()
        self.assertEqual(object_factory.type_of(root_str), TYPE_ROOT)

    def test_weakly_typed_root(self):
        root_str = new_root_object(True).SerializeToString()
        self.assertEqual(object_factory.type_of(root_str), TYPE_UNSET)

    def test_strongly_typed_update(self):
        update_str = new_update_object(False).SerializeToString()
        self.assertEqual(object_factory.type_of(update_str), TYPE_UPDATE)

    def test_weakly_typed_update(self):
        update_str = new_update_object(True).SerializeToString()

        self.assertEqual(object_factory.type_of(update_str), TYPE_UNSET)