897
904
self.assertNotEqual(0, unmigrated())
899
906
self.assertEqual(0, unmigrated())
908
def test_UnusedPOTMsgSetPruner_removes_obsolete_message_sets(self):
909
# UnusedPOTMsgSetPruner removes any POTMsgSet that are
910
# participating in a POTemplate only as obsolete messages.
911
LaunchpadZopelessLayer.switchDbUser('testadmin')
912
pofile = self.factory.makePOFile()
913
translation_message = self.factory.makeCurrentTranslationMessage(
915
translation_message.potmsgset.setSequence(
916
pofile.potemplate, 0)
918
store = IMasterStore(POTMsgSet)
919
obsolete_msgsets = store.find(
921
TranslationTemplateItem.potmsgset == POTMsgSet.id,
922
TranslationTemplateItem.sequence == 0)
923
self.assertNotEqual(0, obsolete_msgsets.count())
925
self.assertEqual(0, obsolete_msgsets.count())
927
def test_UnusedPOTMsgSetPruner_removes_unreferenced_message_sets(self):
928
# If a POTMsgSet is not referenced by any templates the
929
# UnusedPOTMsgSetPruner will remove it.
930
LaunchpadZopelessLayer.switchDbUser('testadmin')
931
potmsgset = self.factory.makePOTMsgSet()
932
# Cheekily drop any references to the POTMsgSet we just created.
933
store = IMasterStore(POTMsgSet)
935
"DELETE FROM TranslationTemplateItem WHERE potmsgset = %s"
938
unreferenced_msgsets = store.find(
942
SQL("SELECT potmsgset FROM TranslationTemplateItem"))))
943
self.assertNotEqual(0, unreferenced_msgsets.count())
945
self.assertEqual(0, unreferenced_msgsets.count())