# Path: groundstation/objects/root_object.py
# class RootObject(base_object.BaseObject):
#     data_members = ["id", "channel", "protocol"]
# 
#     def __init__(self, id, channel, protocol):
#         self.id = id
#         self.channel = channel
#         self.protocol = protocol
#         self._sha1 = None
# 
#     @staticmethod
#     def from_object(obj):
#         """Convert an object straight from Git into a RootObject"""
#         protobuf = root_object_pb2.RootObject()
#         protobuf.ParseFromString(obj)
#         return RootObject(protobuf.id, protobuf.channel, protobuf.protocol)
# 
#     def as_object(self):
#         """Convert a RootObject into data suitable to write into the database
#         as a Git object"""
#         protobuf = root_object_pb2.RootObject()
#         for member in self.data_members:
#             setattr(protobuf, member, getattr(self, member))
#         return protobuf.SerializeToString()
# 
#     def as_json(self):
#         return {
#                 "id": self.id,
#                 "channel": self.channel,
#                 "protocol": self.protocol
#                 }
# 
# Path: groundstation/objects/update_object.py
# class UpdateObject(base_object.BaseObject):
#     data_members = ["parents", "data"]
# 
#     def __init__(self, parents, data):
#         self.parents = parents
#         self.data = data
#         self._sha1 = None
# 
#     @staticmethod
#     def from_object(obj):
#         """Convert an object straight from Git into a RootObject"""
#         protobuf = update_object_pb2.UpdateObject()
#         protobuf.ParseFromString(obj)
#         return UpdateObject(protobuf.parents, protobuf.data)
# 
#     def as_object(self):
#         """Convert a RootObject into data suitable to write into the database
#         as a Git object"""
#         protobuf = update_object_pb2.UpdateObject()
#         protobuf.parents.extend(self.parents)
#         protobuf.data = self.data
#         return protobuf.SerializeToString()


import unittest
import groundstation.objects.object_factory as object_factory
from groundstation.objects.root_object import RootObject
from groundstation.objects.update_object import UpdateObject


class TestRootObject(unittest.TestCase):
    def test_hydrate_root_object(self):
        root = RootObject(
                "test_object",
                "richo@psych0tik.net:groundstation/tests",
                "richo@psych0tik.net:groundstation/testcase"
            )
        hydrated_root = object_factory.hydrate_object(root.as_object())

# Path: groundstation/objects/root_object.py
# class RootObject(base_object.BaseObject):
#     data_members = ["id", "channel", "protocol"]
# 
#     def __init__(self, id, channel, protocol):
#         self.id = id
#         self.channel = channel
#         self.protocol = protocol
#         self._sha1 = None
# 
#     @staticmethod
#     def from_object(obj):
#         """Convert an object straight from Git into a RootObject"""
#         protobuf = root_object_pb2.RootObject()
#         protobuf.ParseFromString(obj)
#         return RootObject(protobuf.id, protobuf.channel, protobuf.protocol)
# 
#     def as_object(self):
#         """Convert a RootObject into data suitable to write into the database
#         as a Git object"""
#         protobuf = root_object_pb2.RootObject()
#         for member in self.data_members:
#             setattr(protobuf, member, getattr(self, member))
#         return protobuf.SerializeToString()
# 
#     def as_json(self):
#         return {
#                 "id": self.id,
#                 "channel": self.channel,
#                 "protocol": self.protocol
#                 }
# 
# Path: groundstation/objects/update_object.py
# class UpdateObject(base_object.BaseObject):
#     data_members = ["parents", "data"]
# 
#     def __init__(self, parents, data):
#         self.parents = parents
#         self.data = data
#         self._sha1 = None
# 
#     @staticmethod
#     def from_object(obj):
#         """Convert an object straight from Git into a RootObject"""
#         protobuf = update_object_pb2.UpdateObject()
#         protobuf.ParseFromString(obj)
#         return UpdateObject(protobuf.parents, protobuf.data)
# 
#     def as_object(self):
#         """Convert a RootObject into data suitable to write into the database
#         as a Git object"""
#         protobuf = update_object_pb2.UpdateObject()
#         protobuf.parents.extend(self.parents)
#         protobuf.data = self.data
#         return protobuf.SerializeToString()


# Path: test/test_object_factory.py
import unittest
import groundstation.objects.object_factory as object_factory
from groundstation.objects.root_object import RootObject
from groundstation.objects.update_object import UpdateObject



class TestRootObject(unittest.TestCase):
    def test_hydrate_root_object(self):
        root = RootObject(
                "test_object",
                "richo@psych0tik.net:groundstation/tests",
                "richo@psych0tik.net:groundstation/testcase"
            )
        hydrated_root = object_factory.hydrate_object(root.as_object())

        self.assertTrue(isinstance(hydrated_root, RootObject))