~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/factory.py

[r=jtv][ui=none][no-qa] Improved tests for
        translations.ProductSeriesView and ProductSeriesLanguagesView.
        LaunchpadObjectFactory does not require a language code for
        POFiles and such anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
729
729
            PollSecrecy.SECRET, allowspoilt=True,
730
730
            poll_type=poll_type)
731
731
 
732
 
    def makeTranslationGroup(
733
 
        self, owner=None, name=None, title=None, summary=None, url=None):
 
732
    def makeTranslationGroup(self, owner=None, name=None, title=None,
 
733
                             summary=None, url=None):
734
734
        """Create a new, arbitrary `TranslationGroup`."""
735
735
        if owner is None:
736
736
            owner = self.makePerson()
743
743
        return getUtility(ITranslationGroupSet).new(
744
744
            name, title, summary, url, owner)
745
745
 
746
 
    def makeTranslator(
747
 
        self, language_code, group=None, person=None, license=True):
 
746
    def makeTranslator(self, language_code=None, group=None, person=None,
 
747
                       license=True, language=None):
748
748
        """Create a new, arbitrary `Translator`."""
749
 
        language = getUtility(ILanguageSet).getLanguageByCode(language_code)
 
749
        assert language_code is None or language is None, (
 
750
            "Please specifiy only one of language_code and language.")
 
751
        if language_code is None:
 
752
            if language is None:
 
753
                language = self.makeLanguage()
 
754
            language_code = language.code
 
755
        else:
 
756
            language = getUtility(ILanguageSet).getLanguageByCode(
 
757
                language_code)
 
758
            if language is None:
 
759
                language = self.makeLanguage(language_code=language_code)
 
760
 
750
761
        if group is None:
751
762
            group = self.makeTranslationGroup()
752
763
        if person is None:
755
766
        tx_person.translations_relicensing_agreement = license
756
767
        return getUtility(ITranslatorSet).new(group, language, person)
757
768
 
758
 
    def makeMilestone(
759
 
        self, product=None, distribution=None, productseries=None, name=None):
 
769
    def makeMilestone(self, product=None, distribution=None,
 
770
                      productseries=None, name=None):
760
771
        if product is None and distribution is None and productseries is None:
761
772
            product = self.makeProduct()
762
773
        if distribution is None:
2280
2291
            self.makePOFile(language_code, template, template.owner)
2281
2292
        return template
2282
2293
 
2283
 
    def makePOFile(self, language_code, potemplate=None, owner=None,
2284
 
                   create_sharing=False, variant=None):
 
2294
    def makePOFile(self, language_code=None, potemplate=None, owner=None,
 
2295
                   create_sharing=False, language=None, variant=None):
2285
2296
        """Make a new translation file."""
 
2297
        assert language_code is None or language is None, (
 
2298
            "Please specifiy only one of language_code and language.")
 
2299
        if language_code is None:
 
2300
            if language is None:
 
2301
                language = self.makeLanguage()
 
2302
            language_code = language.code
2286
2303
        if potemplate is None:
2287
2304
            potemplate = self.makePOTemplate(owner=owner)
2288
2305
        pofile = potemplate.newPOFile(language_code,