def test_restrictProductSeries(self): trunk = self.factory.makeProduct().getSeries('trunk') template = self.factory.makePOTemplate(productseries=trunk) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) self.assertContentEqual([template], by_series.select())
def test_restrictProductSeries(self): trunk = self.factory.makeProduct().getSeries('trunk') template = self.factory.makePOTemplate(productseries=trunk) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) self.assertContentEqual([template], by_series.select())
def test_restrictName(self): trunk = self.factory.makeProduct().getSeries('trunk') template = self.factory.makePOTemplate(productseries=trunk) template_name = template.name # Other template that will not be returned. self.factory.makePOTemplate(productseries=trunk) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) same_name_templates = by_series.restrictName(template_name) self.assertContentEqual([template], same_name_templates.select())
def test_restrictName(self): trunk = self.factory.makeProduct().getSeries('trunk') template = self.factory.makePOTemplate(productseries=trunk) template_name = template.name # Other template that will not be returned. self.factory.makePOTemplate(productseries=trunk) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) same_name_templates = by_series.restrictName(template_name) self.assertContentEqual( [template], same_name_templates.select())
def test_restrictCurrent_obsolete(self): trunk = self.factory.makeProduct().getSeries('trunk') template = self.factory.makePOTemplate(productseries=trunk) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) obsolete_templates = by_series.restrictCurrent(False) removeSecurityProxy(template).iscurrent = True self.assertContentEqual([], obsolete_templates.select()) removeSecurityProxy(template).iscurrent = False self.assertContentEqual([template], obsolete_templates.select())
def test_restrictCurrent_obsolete(self): trunk = self.factory.makeProduct().getSeries('trunk') template = self.factory.makePOTemplate(productseries=trunk) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) obsolete_templates = by_series.restrictCurrent(False) removeSecurityProxy(template).iscurrent = True self.assertContentEqual([], obsolete_templates.select()) removeSecurityProxy(template).iscurrent = False self.assertContentEqual( [template], obsolete_templates.select())
def test_joinPOFile(self): trunk = self.factory.makeProduct().getSeries('trunk') translated_template = self.factory.makePOTemplate(productseries=trunk) self.factory.makePOTemplate(productseries=trunk) nl = translated_template.newPOFile('nl') de = translated_template.newPOFile('de') collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) joined = by_series.joinPOFile() self.assertContentEqual([(translated_template, nl), (translated_template, de)], joined.select(POTemplate, POFile))
def test_joinPOFile(self): trunk = self.factory.makeProduct().getSeries('trunk') translated_template = self.factory.makePOTemplate(productseries=trunk) untranslated_template = self.factory.makePOTemplate( productseries=trunk) nl = translated_template.newPOFile('nl') de = translated_template.newPOFile('de') collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) joined = by_series.joinPOFile() self.assertContentEqual( [(translated_template, nl), (translated_template, de)], joined.select(POTemplate, POFile))
def test_joinOuterPOFile_language(self): trunk = self.factory.makeProduct().getSeries('trunk') translated_template = self.factory.makePOTemplate(productseries=trunk) untranslated_template = self.factory.makePOTemplate( productseries=trunk) nl = translated_template.newPOFile('nl') de = translated_template.newPOFile('de') collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) joined = by_series.joinOuterPOFile(language=nl.language) expected_outcome = [ (translated_template, nl), (untranslated_template, None), ] self.assertContentEqual(expected_outcome, joined.select(POTemplate, POFile))
def test_joinOuterPOFile_language(self): trunk = self.factory.makeProduct().getSeries('trunk') translated_template = self.factory.makePOTemplate(productseries=trunk) untranslated_template = self.factory.makePOTemplate( productseries=trunk) nl = translated_template.newPOFile('nl') de = translated_template.newPOFile('de') collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) joined = by_series.joinOuterPOFile(language=nl.language) expected_outcome = [ (translated_template, nl), (untranslated_template, None), ] self.assertContentEqual( expected_outcome, joined.select(POTemplate, POFile))
def test_restrictProductSeries_restricts(self): # restrictProductSeries makes the collection ignore templates # from other productseries and source packages. product = self.factory.makeProduct() trunk = product.getSeries('trunk') nontrunk = removeSecurityProxy(product).newSeries( product.owner, 'nontrunk', 'foo') sourcepackage = self.factory.makeSourcePackage() self.factory.makePOTemplate(productseries=nontrunk) self.factory.makePOTemplate( distroseries=sourcepackage.distroseries, sourcepackagename=sourcepackage.sourcepackagename) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) self.assertContentEqual([], by_series.select())
def test_restrictProductSeries_restricts(self): # restrictProductSeries makes the collection ignore templates # from other productseries and source packages. product = self.factory.makeProduct() trunk = product.getSeries('trunk') nontrunk = removeSecurityProxy(product).newSeries( product.owner, 'nontrunk', 'foo') sourcepackage = self.factory.makeSourcePackage() self.factory.makePOTemplate(productseries=nontrunk) self.factory.makePOTemplate( distroseries=sourcepackage.distroseries, sourcepackagename=sourcepackage.sourcepackagename) collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) self.assertContentEqual([], by_series.select())
def test_none_found(self): trunk = self.factory.makeProduct().getSeries('trunk') collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) self.assertContentEqual([], by_series.select())
def test_none_found(self): trunk = self.factory.makeProduct().getSeries('trunk') collection = TranslationTemplatesCollection() by_series = collection.restrictProductSeries(trunk) self.assertContentEqual([], by_series.select())