# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


from tmapi.exceptions import ModelConstraintException
from tmapi_test_case import TMAPITestCase
"""Module containing tests for the Topic model.

Most if not all of these tests are ported from the public domain tests
that come with the TMAPI 2.0 distribution (http://www.tmapi.org/2.0/).

"""




class TopicTest (TMAPITestCase):

    def test_parent (self):
        """Tests the parent/child relationship between topic map and topic."""
        parent = self.create_topic_map('http://www.tmapi.org/test/topic/parent')
        self.assertEqual(0, parent.get_topics().count(),
                         'Expected new topic map to be created with no topics')
        topic = parent.create_topic()
        self.assertEqual(parent, topic.get_parent(),
                         'Unexpceted topic parent after creation')
        self.assertEqual(1, parent.get_topics().count(),
                         'Expected topic list size to increment for topic map')
        self.assertTrue(topic in parent.get_topics(),
                        'Topic is not part of get_topics()')
        topic.remove()
        self.assertEqual(0, parent.get_topics().count(),
                         'Expected topic list size to decrement for topic map')

    def test_add_subject_identifier_illegal (self):
        topic = self.create_topic()

# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


# Path: tmapi/tests/models/test_topic.py
from tmapi.exceptions import ModelConstraintException
from tmapi_test_case import TMAPITestCase

"""Module containing tests for the Topic model.

Most if not all of these tests are ported from the public domain tests
that come with the TMAPI 2.0 distribution (http://www.tmapi.org/2.0/).

"""




class TopicTest (TMAPITestCase):

    def test_parent (self):
        """Tests the parent/child relationship between topic map and topic."""
        parent = self.create_topic_map('http://www.tmapi.org/test/topic/parent')
        self.assertEqual(0, parent.get_topics().count(),
                         'Expected new topic map to be created with no topics')
        topic = parent.create_topic()
        self.assertEqual(parent, topic.get_parent(),
                         'Unexpceted topic parent after creation')
        self.assertEqual(1, parent.get_topics().count(),
                         'Expected topic list size to increment for topic map')
        self.assertTrue(topic in parent.get_topics(),
                        'Topic is not part of get_topics()')
        topic.remove()
        self.assertEqual(0, parent.get_topics().count(),
                         'Expected topic list size to decrement for topic map')

    def test_add_subject_identifier_illegal (self):
        topic = self.create_topic()

        self.assertRaises(ModelConstraintException,