Esempio n. 1
0
class ResourceManagerTest(unittest.TestCase):
    
    def setUp(self):
        self.sut = ResourceManager()
        
    def testGetString(self):
        self.assertEqual(self.sut.getString("telegram_error"), "Telegram error: ")
        
    def testGetString(self):
        self.assertEqual(self.sut.getNumber("max_preamble_length"), 4000)
Esempio n. 2
0
class PreambleManagerTest(unittest.TestCase):
    def setUp(self):
        self.resourceManager = ResourceManager()
        self.sut = PreambleManager(self.resourceManager)

    def testValidatePreamble(self):
        self.assertEqual(
            self.sut.validatePreamble(self.sut.getDefaultPreamble()),
            (True, ""))

        incorrect_preamble = "\documentclass[12pt]{arti}"
        self.assertEqual(
            self.sut.validatePreamble(incorrect_preamble),
            (False, self.resourceManager.getString("preamble_invalid")))

        too_long_preamble = Mock()
        too_long_preamble.__len__ = Mock(return_value=self.resourceManager.
                                         getNumber("max_preamble_length") + 1)
        message = self.resourceManager.getString(
            "preamble_too_long") % self.resourceManager.getNumber(
                "max_preamble_length")
        self.assertEqual(self.sut.validatePreamble(too_long_preamble),
                         (False, message))