本文整理汇总了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)
示例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": []
})
示例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)
示例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()
示例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()
示例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'))
示例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())
示例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)
示例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()
示例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)
示例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')
示例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')
示例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'))