Пример #1
0
 def test_add_text_representation(self):
     # Create text representations
     text = TextRepresentation()
     repr = TextRepresentation()
     # Test add text representations to the context
     self.assertIs(self.context.add_text_representation(text), self.context)
     self.assertListEqual(self.context.text_representation, [text])
     self.assertIs(self.context.add_text_representation(repr), self.context)
     self.assertListEqual(self.context.text_representation, [text, repr])
     # Release TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
Пример #2
0
 def test_get_text_representations(self):
     # List of TextRepresentation instances is empty
     self.assertListEqual(self.context.get_text_representations(), [])
     # Create TextRepresentation instances and add them to the list
     text = TextRepresentation()
     repr = TextRepresentation()
     self.context.text_representation = [text, repr]
     # Test get text representations
     self.assertListEqual(self.context.get_text_representations(),
                          [text, repr])
     # Delete TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
Пример #3
0
 def test_get_last_text_representation(self):
     # List of TextRepresentation instances is empty
     self.assertIsNone(self.context.get_last_text_representation())
     # Create TextRepresentation instances and add them to the list
     text = TextRepresentation()
     repr = TextRepresentation()
     self.context.text_representation = [text, repr]
     # Test get last text representation
     self.assertIs(self.context.get_last_text_representation(), repr)
     self.context.text_representation.pop()
     self.assertIs(self.context.get_last_text_representation(), text)
     # Release TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
Пример #4
0
 def test_get_comments(self):
     # List of TextRepresentation instances is empty
     self.assertListEqual(self.context.get_comments(), [])
     # Create TextRepresentation instances and add them to the list
     text = TextRepresentation()
     repr = TextRepresentation()
     self.context.text_representation = [text, repr]
     # Set their comment
     comment1 = "comment1"
     comment2 = "comment2"
     text.comment = comment1
     # Test get comments
     self.assertListEqual(self.context.get_comments(), [comment1])
     repr.comment = comment2
     self.assertListEqual(self.context.get_comments(), [comment1, comment2])
     # Release TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
Пример #5
0
 def test_find_written_forms(self):
     # List of TextRepresentation instances is empty
     self.assertListEqual(self.context.find_written_forms(), [])
     # Create TextRepresentation instances and add them to the list
     text = TextRepresentation()
     repr = TextRepresentation()
     self.context.text_representation = [text, repr]
     # Set their written form and language
     form1 = "form1"
     form2 = "form2"
     lang = "lang"
     text.writtenForm = form1
     text.language = lang
     # Test find written forms
     self.assertListEqual(self.context.find_written_forms(), [form1])
     repr.writtenForm = form2
     self.assertListEqual(self.context.find_written_forms(), [form1, form2])
     # Test with a language filter
     self.assertListEqual(self.context.find_written_forms("eng"), [])
     self.assertListEqual(self.context.find_written_forms(lang), [form1])
     # Release TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
Пример #6
0
 def test_set_comment(self):
     comment = "comment1"
     # Test with an existing text representation
     repr = TextRepresentation()
     self.context.text_representation = [repr]
     self.assertIs(self.context.set_comment(comment), self.context)
     self.assertEqual(len(self.context.text_representation), 1)
     self.assertEqual(self.context.text_representation[0].comment, comment)
     # Test with a new text representation to create
     comment = "comment2"
     self.assertIs(self.context.set_comment(comment), self.context)
     self.assertEqual(len(self.context.text_representation), 2)
     self.assertEqual(self.context.text_representation[1].comment, comment)
     # Release TextRepresentation instance
     del repr
Пример #7
0
 def test_get_comments(self):
     # List of TextRepresentation instances is empty
     self.assertListEqual(self.context.get_comments(), [])
     # Create TextRepresentation instances and add them to the list
     text = TextRepresentation()
     repr = TextRepresentation()
     self.context.text_representation = [text, repr]
     # Set their comment
     comment1 = "comment1"
     comment2 = "comment2"
     text.comment = comment1
     # Test get comments
     self.assertListEqual(self.context.get_comments(), [comment1])
     repr.comment = comment2
     self.assertListEqual(self.context.get_comments(), [comment1, comment2])
     # Release TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
Пример #8
0
 def test_find_written_forms(self):
     # List of TextRepresentation instances is empty
     self.assertListEqual(self.context.find_written_forms(), [])
     # Create TextRepresentation instances and add them to the list
     text = TextRepresentation()
     repr = TextRepresentation()
     self.context.text_representation = [text, repr]
     # Set their written form and language
     form1 = "form1"
     form2 = "form2"
     lang = "lang"
     text.writtenForm = form1
     text.language = lang
     # Test find written forms
     self.assertListEqual(self.context.find_written_forms(), [form1])
     repr.writtenForm = form2
     self.assertListEqual(self.context.find_written_forms(), [form1, form2])
     # Test with a language filter
     self.assertListEqual(self.context.find_written_forms("eng"), [])
     self.assertListEqual(self.context.find_written_forms(lang), [form1])
     # Release TextRepresentation instances
     del self.context.text_representation[:]
     del text, repr
 def setUp(self):
     # Instantiate a TextRepresentation object
     self.text_representation = TextRepresentation()
class TestTextRepresentationFunctions(unittest.TestCase):

    def setUp(self):
        # Instantiate a TextRepresentation object
        self.text_representation = TextRepresentation()

    def tearDown(self):
        # Release instantiated objects
        del self.text_representation

    def test_init(self):
        self.assertIsNone(self.text_representation.comment)
        self.assertIsNone(self.text_representation.writtenForm)
        self.assertIsNone(self.text_representation.language)
        self.assertIsNone(self.text_representation.font)

    def test_set_comment(self):
        comment = "comment"
        self.assertIs(self.text_representation.set_comment(comment), self.text_representation)
        self.assertEqual(self.text_representation.comment, comment)

    def test_get_comment(self):
        comment = "comment"
        self.text_representation.comment = comment
        self.assertEqual(self.text_representation.get_comment(), comment)

    def test_set_writtenForm(self):
        form = "written"
        self.assertIs(self.text_representation.set_writtenForm(form), self.text_representation)
        self.assertEqual(self.text_representation.writtenForm, form)
        # Test with language
        form = "form with lang"
        lang = "lang"
        self.assertIs(self.text_representation.set_writtenForm(form, lang), self.text_representation)
        self.assertEqual(self.text_representation.writtenForm, form)
        self.assertEqual(self.text_representation.language, lang)

    def test_get_writtenForm(self):
        self.assertIsNone(self.text_representation.get_writtenForm())
        form = "written"
        self.text_representation.writtenForm = form
        self.assertEqual(self.text_representation.get_writtenForm(), form)
        # Test with a language filter
        language = "eng"
        self.text_representation.language = language
        self.assertEqual(self.text_representation.get_writtenForm(), form)
        self.assertIsNone(self.text_representation.get_writtenForm("fra"))
        self.assertEqual(self.text_representation.get_writtenForm("eng"), form)

    def test_set_language(self):
        language = "English"
        self.assertIs(self.text_representation.set_language(language), self.text_representation)
        self.assertEqual(self.text_representation.language, language)

    def test_get_language(self):
        language = "language"
        self.text_representation.language = language
        self.assertEqual(self.text_representation.get_language(), language)
Пример #11
0
 def create_text_representation(self):
     """! @brief Create a text representation.
     @return TextRepresentation instance.
     """
     return TextRepresentation()
 def setUp(self):
     # Instantiate a TextRepresentation object
     self.text_representation = TextRepresentation()
class TestTextRepresentationFunctions(unittest.TestCase):
    def setUp(self):
        # Instantiate a TextRepresentation object
        self.text_representation = TextRepresentation()

    def tearDown(self):
        # Release instantiated objects
        del self.text_representation

    def test_init(self):
        self.assertIsNone(self.text_representation.comment)
        self.assertIsNone(self.text_representation.writtenForm)
        self.assertIsNone(self.text_representation.language)
        self.assertIsNone(self.text_representation.font)

    def test_set_comment(self):
        comment = "comment"
        self.assertIs(self.text_representation.set_comment(comment),
                      self.text_representation)
        self.assertEqual(self.text_representation.comment, comment)

    def test_get_comment(self):
        comment = "comment"
        self.text_representation.comment = comment
        self.assertEqual(self.text_representation.get_comment(), comment)

    def test_set_writtenForm(self):
        form = "written"
        self.assertIs(self.text_representation.set_writtenForm(form),
                      self.text_representation)
        self.assertEqual(self.text_representation.writtenForm, form)
        # Test with language
        form = "form with lang"
        lang = "lang"
        self.assertIs(self.text_representation.set_writtenForm(form, lang),
                      self.text_representation)
        self.assertEqual(self.text_representation.writtenForm, form)
        self.assertEqual(self.text_representation.language, lang)

    def test_get_writtenForm(self):
        self.assertIsNone(self.text_representation.get_writtenForm())
        form = "written"
        self.text_representation.writtenForm = form
        self.assertEqual(self.text_representation.get_writtenForm(), form)
        # Test with a language filter
        language = "eng"
        self.text_representation.language = language
        self.assertEqual(self.text_representation.get_writtenForm(), form)
        self.assertIsNone(self.text_representation.get_writtenForm("fra"))
        self.assertEqual(self.text_representation.get_writtenForm("eng"), form)

    def test_set_language(self):
        language = "English"
        self.assertIs(self.text_representation.set_language(language),
                      self.text_representation)
        self.assertEqual(self.text_representation.language, language)

    def test_get_language(self):
        language = "language"
        self.text_representation.language = language
        self.assertEqual(self.text_representation.get_language(), language)