当前位置: 首页>>代码示例>>Python>>正文


Python Package.new方法代码示例

本文整理汇总了Python中models.package.Package.new方法的典型用法代码示例。如果您正苦于以下问题:Python Package.new方法的具体用法?Python Package.new怎么用?Python Package.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.package.Package的用法示例。


在下文中一共展示了Package.new方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_requires_uploader

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_create_requires_uploader(self):
        Package.new(name='owned-package',
                    uploaders=[self.normal_user('owner')]).put()
        self.be_normal_oauth_user()

        response = self.testapp.get(
            '/packages/owned-package/versions/abcd/create.json', status=403)
        self.assert_json_error(response)
开发者ID:kwalrath,项目名称:pub-dartlang,代码行数:10,代码来源:test_package_versions.py

示例2: test_get_package_json_without_versions

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_get_package_json_without_versions(self):
        admin = self.admin_user()
        Package.new(name='test-package', uploaders=[admin]).put()

        response = self.testapp.get('/packages/test-package.json')
        self.assertEqual(response.headers['Content-Type'], 'application/json')
        self.assertEqual(json.loads(response.body), {
            "name": "test-package",
            "uploaders": [admin.email()],
            "versions": []
        })
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:13,代码来源:test_packages.py

示例3: test_api_get_package_without_versions

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_api_get_package_without_versions(self):
        admin = self.admin_user()
        Package.new(name='test-package', uploaders=[admin]).put()

        self.be_normal_user()

        response = self.testapp.get('/api/packages/test-package')
        self.assertEqual(response.headers['Content-Type'], 'application/json')
        result = json.loads(response.body)
        self.assertEqual(result["name"], "test-package")
        self.assertEqual(result["versions"], [])
        self.assertEqual(result["latest"], None)
开发者ID:a14n,项目名称:pub-dartlang,代码行数:14,代码来源:test_packages.py

示例4: setUp

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
 def setUp(self):
     super(PackageVersionsTest, self).setUp()
     self.package = Package.new(
         name='test-package',
         uploaders=[self.admin_user(),
                    self.normal_user('other-uploader')])
     self.package.put()
开发者ID:kwalrath,项目名称:pub-dartlang,代码行数:9,代码来源:test_package_versions.py

示例5: setUp

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
 def setUp(self):
     super(PackageUploadersTest, self).setUp()
     self.package = Package.new(
         name='test-package',
         uploaders=[self.normal_user('uploader1'),
                    self.normal_user('uploader2')])
     self.package.put()
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:9,代码来源:test_package_uploaders.py

示例6: test_has_version

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_has_version(self):
        package = Package.new(name='test-package',
                              uploaders=[self.admin_user()])
        package.put()
        self.package_version(package, '1.2.3').put()

        self.assertTrue(package.has_version('1.2.3'))
        self.assertFalse(package.has_version('1.2.4'))
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:10,代码来源:test_package.py

示例7: test_description

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_description(self):
        package = Package.new(name='test-package',
                              uploaders=[self.admin_user()])
        package.put()

        def get_description():
            return Package.get_by_key_name(package.name).description

        def set_latest_version(version, **additional_pubspec_fields):
            version = self.package_version(
                package, version, **additional_pubspec_fields)
            package.latest_version = version
            version.put()
            package.put()

        self.assertIsNone(get_description())

        set_latest_version('1.2.3')
        self.assertIsNone(get_description())

        set_latest_version('1.2.4', description='some package')
        self.assertEquals('some package', get_description())
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:24,代码来源:test_package.py

示例8: create_package

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
 def create_package(self, name, version):
     """Create and save a package object with a version."""
     Package.new(name=name, uploaders=[users.get_current_user()]).put()
     self.set_latest_version(name, version)
开发者ID:kaisellgren,项目名称:pub-dartlang,代码行数:6,代码来源:testcase.py

示例9: setUp

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
 def setUp(self):
     super(PackageVersionsTest, self).setUp()
     self.package = Package.new(name="test-package", uploaders=[self.admin_user()])
     self.package.put()
开发者ID:butlermatt,项目名称:pub-dartlang,代码行数:6,代码来源:test_package_versions.py

示例10: test_create_requires_uploader

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_create_requires_uploader(self):
        Package.new(name="owned-package", uploaders=[self.normal_user("owner")]).put()
        self.be_normal_user()

        response = self.testapp.get("/packages/owned-package/versions/abcd/create", status=403)
        self.assert_error_page(response)
开发者ID:butlermatt,项目名称:pub-dartlang,代码行数:8,代码来源:test_package_versions.py

示例11: test_get_unowned_package

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_get_unowned_package(self):
        Package.new(name='test-package', uploaders=[self.admin_user()]).put()

        self.be_normal_user()
        response = self.testapp.get('/packages/test-package')
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:7,代码来源:test_packages.py

示例12: test_get_owned_package

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_get_owned_package(self):
        Package.new(name='test-package', uploaders=[self.admin_user()]).put()

        self.be_admin_user()
        response = self.testapp.get('/packages/test-package')
        self.assert_link(response, '/packages/test-package/versions/new')
开发者ID:amouravski,项目名称:pub-dartlang,代码行数:8,代码来源:test_packages.py

示例13: test_exists

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import new [as 别名]
    def test_exists(self):
        Package.new(name='test-package', uploaders=[self.admin_user()]).put()

        self.assertTrue(Package.exists('test-package'))
        self.assertFalse(Package.exists('other-package'))
开发者ID:Mixbook,项目名称:pub-dartlang,代码行数:7,代码来源:test_package.py


注:本文中的models.package.Package.new方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。