~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

[r=sinzui][bug=798764, 820210, 820212,
        820213] Add affiliation adapters for question, branch,
        specification, distro, product, distroseries, productseries

Show diffs side-by-side

added added

removed removed

Lines of Context:
954
954
        licenses=None, owner=None, registrant=None,
955
955
        title=None, summary=None, official_malone=None,
956
956
        translations_usage=None, bug_supervisor=None,
957
 
        driver=None):
 
957
        driver=None, security_contact=None):
958
958
        """Create and return a new, arbitrary Product."""
959
959
        if owner is None:
960
960
            owner = self.makePerson()
990
990
            naked_product.bug_supervisor = bug_supervisor
991
991
        if driver is not None:
992
992
            naked_product.driver = driver
 
993
        if security_contact is not None:
 
994
            naked_product.security_contact = security_contact
993
995
        return product
994
996
 
995
997
    def makeProductSeries(self, product=None, name=None, owner=None,
1023
1025
        return ProxyFactory(series)
1024
1026
 
1025
1027
    def makeProject(self, name=None, displayname=None, title=None,
1026
 
                    homepageurl=None, summary=None, owner=None,
 
1028
                    homepageurl=None, summary=None, owner=None, driver=None,
1027
1029
                    description=None):
1028
1030
        """Create and return a new, arbitrary ProjectGroup."""
1029
1031
        if owner is None:
1038
1040
            description = self.getUniqueString('description')
1039
1041
        if title is None:
1040
1042
            title = self.getUniqueString('title')
1041
 
        return getUtility(IProjectGroupSet).new(
 
1043
        project = getUtility(IProjectGroupSet).new(
1042
1044
            name=name,
1043
1045
            displayname=displayname,
1044
1046
            title=title,
1046
1048
            summary=summary,
1047
1049
            description=description,
1048
1050
            owner=owner)
 
1051
        if driver is not None:
 
1052
            removeSecurityProxy(project).driver = driver
 
1053
        return project
1049
1054
 
1050
1055
    def makeSprint(self, title=None, name=None):
1051
1056
        """Make a sprint."""
2324
2329
 
2325
2330
    def makeDistribution(self, name=None, displayname=None, owner=None,
2326
2331
                         registrant=None, members=None, title=None,
2327
 
                         aliases=None, bug_supervisor=None,
2328
 
                         publish_root_dir=None, publish_base_url=None,
2329
 
                         publish_copy_base_url=None, no_pubconf=False):
 
2332
                         aliases=None, bug_supervisor=None, driver=None,
 
2333
                         security_contact=None, publish_root_dir=None,
 
2334
                         publish_base_url=None, publish_copy_base_url=None,
 
2335
                         no_pubconf=False):
2330
2336
        """Make a new distribution."""
2331
2337
        if name is None:
2332
2338
            name = self.getUniqueString(prefix="distribution")
2346
2352
        distro = getUtility(IDistributionSet).new(
2347
2353
            name, displayname, title, description, summary, domainname,
2348
2354
            members, owner, registrant)
 
2355
        naked_distro = removeSecurityProxy(distro)
2349
2356
        if aliases is not None:
2350
 
            removeSecurityProxy(distro).setAliases(aliases)
 
2357
            naked_distro.setAliases(aliases)
 
2358
        if driver is not None:
 
2359
            naked_distro.driver = driver
2351
2360
        if bug_supervisor is not None:
2352
 
            naked_distro = removeSecurityProxy(distro)
2353
2361
            naked_distro.bug_supervisor = bug_supervisor
 
2362
        if security_contact is not None:
 
2363
            naked_distro.security_contact = security_contact
2354
2364
        if not no_pubconf:
2355
2365
            self.makePublisherConfig(
2356
2366
                distro, publish_root_dir, publish_base_url,