def test_caches_current_ubuntu_message(self):
     pofile = self._makeUbuntuPOFile()
     current_message = self.factory.makeCurrentTranslationMessage(
         pofile=pofile)
     cached_file = ExistingPOFileInDatabase(pofile)
     message_data = self.getTranslationMessageData(current_message)
     self.assertTrue(cached_file.isAlreadyTranslatedTheSame(message_data))
 def test_caches_current_ubuntu_message(self):
     pofile = self._makeUbuntuPOFile()
     current_message = self.factory.makeCurrentTranslationMessage(
         pofile=pofile)
     cached_file = ExistingPOFileInDatabase(pofile)
     message_data = self.getTranslationMessageData(current_message)
     self.assertTrue(cached_file.isAlreadyTranslatedTheSame(message_data))
    def test_does_not_cache_ubuntu_message_for_upstream_import(self):
        pofile = self._makeUpstreamPOFile()
        ubuntu_message = self.factory.makeSuggestion(pofile=pofile)
        ubuntu_message.is_current_ubuntu = True

        cached_file = ExistingPOFileInDatabase(pofile)
        message_data = self.getTranslationMessageData(ubuntu_message)
        self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
 def test_does_not_cache_inactive_message(self):
     # Non-current messages (i.e. suggestions) are not cached in
     # ExistingPOFileInDatabase.
     pofile = self._makeUpstreamPOFile()
     inactive_message = self.factory.makeSuggestion(pofile=pofile)
     cached_file = ExistingPOFileInDatabase(pofile)
     message_data = self.getTranslationMessageData(inactive_message)
     self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
    def test_does_not_cache_ubuntu_message_for_upstream_import(self):
        pofile = self._makeUpstreamPOFile()
        ubuntu_message = self.factory.makeSuggestion(pofile=pofile)
        ubuntu_message.is_current_ubuntu = True

        cached_file = ExistingPOFileInDatabase(pofile)
        message_data = self.getTranslationMessageData(ubuntu_message)
        self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
 def test_does_not_cache_inactive_message(self):
     # Non-current messages (i.e. suggestions) are not cached in
     # ExistingPOFileInDatabase.
     pofile = self._makeUpstreamPOFile()
     inactive_message = self.factory.makeSuggestion(pofile=pofile)
     cached_file = ExistingPOFileInDatabase(pofile)
     message_data = self.getTranslationMessageData(inactive_message)
     self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
 def test_caches_current_upstream_message(self):
     # Current upstream TranslationMessages are properly cached in
     # ExistingPOFileInDatabase.
     pofile = self._makeUpstreamPOFile()
     current_message = self.factory.makeCurrentTranslationMessage(
         pofile=pofile)
     cached_file = ExistingPOFileInDatabase(pofile)
     message_data = self.getTranslationMessageData(current_message)
     self.assertTrue(cached_file.isAlreadyTranslatedTheSame(message_data))
 def test_caches_current_upstream_message(self):
     # Current upstream TranslationMessages are properly cached in
     # ExistingPOFileInDatabase.
     pofile = self._makeUpstreamPOFile()
     current_message = self.factory.makeCurrentTranslationMessage(
         pofile=pofile)
     cached_file = ExistingPOFileInDatabase(pofile)
     message_data = self.getTranslationMessageData(current_message)
     self.assertTrue(cached_file.isAlreadyTranslatedTheSame(message_data))
    def test_query_timeout(self):
        # Test that super-fast-imports doesn't cache anything when it hits
        # a timeout.
        pofile = self.factory.makePOFile()

        # Add a message that would otherwise be cached (see other tests).
        current_message = self.factory.makeCurrentTranslationMessage(
            pofile=pofile)
        message_data = self.getTranslationMessageData(current_message)
        cached_file = ExistingPOFileInDatabase(pofile, simulate_timeout=True)
        self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))
    def test_query_timeout(self):
        # Test that super-fast-imports doesn't cache anything when it hits
        # a timeout.
        pofile = self.factory.makePOFile()

        # Add a message that would otherwise be cached (see other tests).
        current_message = self.factory.makeCurrentTranslationMessage(
            pofile=pofile)
        message_data = self.getTranslationMessageData(current_message)
        cached_file = ExistingPOFileInDatabase(pofile, simulate_timeout=True)
        self.assertFalse(cached_file.isAlreadyTranslatedTheSame(message_data))