本文整理汇总了Python中tests.create_package函数的典型用法代码示例。如果您正苦于以下问题:Python create_package函数的具体用法?Python create_package怎么用?Python create_package使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_package函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_score
def test_score(self):
""" Test the scores """
output = self.app.get("/api/v1/score/pingou/")
self.assertEqual(output.status_code, 404)
output = json.loads(output.data)
self.assertEqual(output.keys(), ["output", "error"])
self.assertEqual(output["output"], "notok")
self.assertEqual(output["error"], "User not found")
create_package(self.session)
create_tag(self.session)
output = self.app.get("/api/v1/score/pingou/")
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output.keys(), ["score", "gravatar", "name"])
self.assertEqual(output["name"], "pingou")
self.assertEqual(output["score"], 8)
output = self.app.get("/api/v1/score/toshio/")
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output.keys(), ["score", "gravatar", "name"])
self.assertEqual(output["name"], "toshio")
self.assertEqual(output["score"], 2)
开发者ID:00willo,项目名称:fedora-tagger,代码行数:25,代码来源:test_flask_api.py
示例2: test_api_repr
def test_api_repr(self):
""" Test the api_repr function of Package. """
create_package(self.session)
package = model.Package.by_name(self.session, 'guake')
package = package.api_repr(1)
self.assertEqual(package.keys(), ['upstreamurl', 'name',
'reviewurl', 'summary'])
开发者ID:ralphbean,项目名称:packagedb2,代码行数:7,代码来源:test_package.py
示例3: test_search
def test_search(self):
""" Test the search function of Package. """
create_package(self.session)
packages = model.Package.search(
session=self.session,
pkg_name='g%')
self.assertEqual(len(packages), 2)
self.assertEqual(packages[0].name, 'guake')
self.assertEqual(packages[1].name, 'geany')
packages = model.Package.search(
session=self.session,
pkg_name='g%',
limit=1)
self.assertEqual(len(packages), 1)
self.assertEqual(packages[0].name, 'guake')
packages = model.Package.search(
session=self.session,
pkg_name='g%',
offset=1)
self.assertEqual(len(packages), 1)
self.assertEqual(packages[0].name, 'geany')
packages = model.Package.search(
session=self.session,
pkg_name='g%',
count=True)
self.assertEqual(packages, 2)
开发者ID:ralphbean,项目名称:packagedb2,代码行数:30,代码来源:test_package.py
示例4: test_pkg_ratings
def test_pkg_ratings(self):
""" Test the pkg_ratings function. """
output = self.app.get("/api/v1/ratings/guake")
self.assertEqual(output.status_code, 301)
output = self.app.get("/api/v1/ratings/guake/")
self.assertEqual(output.status_code, 404)
output = json.loads(output.data)
self.assertEqual(output["output"], "notok")
self.assertEqual(output["error"], 'Package "guake" not found')
create_package(self.session)
output = self.app.get("/api/v1/ratings/guake,geany/")
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(len(output["ratings"]), 2)
self.assertEqual(output["ratings"][0]["rating"], -1)
self.assertEqual(output["ratings"][0]["name"], "guake")
self.assertEqual(output["ratings"][1]["rating"], -1)
self.assertEqual(output["ratings"][1]["name"], "geany")
create_rating(self.session)
output = self.app.get("/api/v1/ratings/guake,geany/")
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(len(output["ratings"]), 2)
self.assertEqual(output["ratings"][0]["name"], "guake")
self.assertEqual(output["ratings"][0]["rating"], 75)
self.assertEqual(output["ratings"][1]["name"], "geany")
self.assertEqual(output["ratings"][1]["rating"], 100.0)
开发者ID:00willo,项目名称:fedora-tagger,代码行数:33,代码来源:test_flask_api.py
示例5: test_pkg_get_tag
def test_pkg_get_tag(self):
""" Test the pkg_get_tag function. """
output = self.app.get("/api/v1/guake/tag")
self.assertEqual(output.status_code, 301)
output = self.app.get("/api/v1/guake/tag/")
self.assertEqual(output.status_code, 404)
output = json.loads(output.data)
self.assertEqual(output["output"], "notok")
self.assertEqual(output["error"], 'Package "guake" not found')
create_package(self.session)
output = self.app.get("/api/v1/guake/tag/")
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output["name"], "guake")
self.assertEqual(output["tags"], [])
create_tag(self.session)
output = self.app.get("/api/v1/guake/tag/")
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output["name"], "guake")
self.assertEqual(output["tags"][0]["tag"], u"gnóme")
self.assertEqual(output["tags"][0]["votes"], 2)
self.assertEqual(output["tags"][0]["like"], 2)
self.assertEqual(output["tags"][0]["dislike"], 0)
self.assertEqual(output["tags"][1]["tag"], "terminal")
self.assertEqual(output["tags"][0]["votes"], 2)
self.assertEqual(output["tags"][0]["like"], 2)
self.assertEqual(output["tags"][0]["dislike"], 0)
开发者ID:00willo,项目名称:fedora-tagger,代码行数:34,代码来源:test_flask_api.py
示例6: test_pkg_get_rating
def test_pkg_get_rating(self):
""" Test the pkg_get_rating function. """
output = self.app.get('/api/v1/guake/rating')
self.assertEqual(output.status_code, 301)
output = self.app.get('/api/v1/guake/rating/')
self.assertEqual(output.status_code, 404)
output = json.loads(output.data)
self.assertEqual(output['output'], 'notok')
self.assertEqual(output['error'], 'Package "guake" not found')
create_package(self.session)
output = self.app.get('/api/v1/guake/rating/')
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output['rating'], -1.0)
self.assertEqual(output['name'], 'guake')
create_rating(self.session)
output = self.app.get('/api/v1/guake/rating/')
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output['rating'], 75.0)
self.assertEqual(output['name'], 'guake')
开发者ID:bnprk,项目名称:fedora-tagger,代码行数:27,代码来源:test_flask_api.py
示例7: test_rating_get
def test_rating_get(self):
""" Test the rating_get function. """
output = self.app.get('/api/v1/rating/75')
self.assertEqual(output.status_code, 301)
output = self.app.get('/api/v1/rating/76/')
self.assertEqual(output.status_code, 404)
output = json.loads(output.data)
self.assertEqual(output['output'], 'notok')
self.assertEqual(output['error'],
'No packages found with rating "76.0"')
output = self.app.get('/api/v1/rating/as/')
self.assertEqual(output.status_code, 500)
create_package(self.session)
create_rating(self.session)
output = self.app.get('/api/v1/rating/75/')
self.assertEqual(output.status_code, 200)
output = json.loads(output.data)
self.assertEqual(output['rating'], 75)
self.assertEqual(len(output['packages']), 1)
self.assertEqual(output['packages'][0], 'guake')
开发者ID:bnprk,项目名称:fedora-tagger,代码行数:25,代码来源:test_flask_api.py
示例8: test_tag_sqlite
def test_tag_sqlite(self):
""" Test tag_pkg_sqlite.
A url for bodhi's masher.
"""
create_package(self.session)
create_tag(self.session)
output = self.app.get('/api/v1/tag/sqlitebuildtags/')
self.assertEqual(output.status_code, 200)
fd, db_filename = tempfile.mkstemp()
os.close(fd)
with open(db_filename, 'w') as f:
f.write(output.data)
with sqlite3.connect(db_filename) as conn:
cursor = conn.cursor();
cursor.execute("select * from packagetags;")
rows = cursor.fetchall()
target_rows = [
(u'guake', u'gnóme', 2),
(u'guake', u'terminal', 2),
(u'geany', u'gnóme', 2),
(u'geany', u'ide', 2),
]
self.assertEqual(len(rows), len(target_rows))
for actual, target in zip(rows, target_rows):
self.assertEqual(actual, target)
开发者ID:bnprk,项目名称:fedora-tagger,代码行数:31,代码来源:test_flask_api.py
示例9: test_add_rating
def test_add_rating(self):
""" Test the add_rating function of taggerlib. """
create_user(self.session)
user_pingou = model.FASUser.by_name(self.session, 'pingou')
user_ralph = model.FASUser.by_name(self.session, 'ralph')
create_package(self.session)
out = fedoratagger.lib.add_rating(self.session, 'guake', 100,
user_pingou)
self.assertEqual(out, 'Rating "100" added to the package "guake"')
self.session.commit()
pkg = model.Package.by_name(self.session, 'guake')
rating = model.Rating.rating_of_package(self.session, pkg.id)
self.assertEqual(100, rating)
out = fedoratagger.lib.add_rating(self.session, 'guake', 50,
user_pingou)
self.assertEqual(out, 'Rating on package "guake" changed to "50"')
self.session.commit()
out = fedoratagger.lib.add_rating(self.session, 'guake', 50,
user_pingou)
self.assertEqual(out, 'Rating on package "guake" did not change')
self.session.commit()
out = fedoratagger.lib.add_rating(self.session, 'guake', 100,
user_ralph)
self.assertEqual(out, 'Rating "100" added to the package "guake"')
self.session.commit()
rating = model.Rating.rating_of_package(self.session, pkg.id)
self.assertEqual(75, rating)
r = fedoratagger.lib.model.Package.rating(pkg, self.session)
self.assertEquals(75, r)
开发者ID:00willo,项目名称:fedora-tagger,代码行数:35,代码来源:test_taggerlib.py
示例10: test_statistics
def test_statistics(self):
""" Test the statistics method. """
out = fedoratagger.lib.statistics(self.session)
self.assertEqual(['summary'], out.keys())
self.assertEqual(0, out['summary']['with_tags'])
self.assertEqual(0, out['summary']['no_tags'])
self.assertEqual(0, out['summary']['tags_per_package'])
self.assertEqual(0, out['summary']['tags_per_package_no_zeroes'])
self.assertEqual(0, out['summary']['total_packages'])
self.assertEqual(0, out['summary']['total_unique_tags'])
create_package(self.session)
out = fedoratagger.lib.statistics(self.session)
self.assertEqual(['summary'], out.keys())
self.assertEqual(0, out['summary']['with_tags'])
self.assertEqual(3, out['summary']['no_tags'])
self.assertEqual(0, out['summary']['tags_per_package'])
self.assertEqual(0, out['summary']['tags_per_package_no_zeroes'])
self.assertEqual(3, out['summary']['total_packages'])
self.assertEqual(0, out['summary']['total_unique_tags'])
create_tag(self.session)
out = fedoratagger.lib.statistics(self.session)
self.assertEqual(['summary'], out.keys())
self.assertEqual(2, out['summary']['with_tags'])
self.assertEqual(1, out['summary']['no_tags'])
self.assertEqual(4/float(3), out['summary']['tags_per_package'])
self.assertEqual(2, out['summary']['tags_per_package_no_zeroes'])
self.assertEqual(3, out['summary']['total_packages'])
self.assertEqual(3, out['summary']['total_unique_tags'])
开发者ID:00willo,项目名称:fedora-tagger,代码行数:30,代码来源:test_taggerlib.py
示例11: test_packages__repr__
def test_packages__repr__(self):
""" Test the Packages.__repr__ function. """
create_project(self.session)
create_distro(self.session)
create_package(self.session)
pkg = model.Packages.by_id(self.session, 1)
self.assertEqual(str(pkg), '<Packages(1, Fedora: geany)>')
开发者ID:ncoghlan,项目名称:anitya,代码行数:8,代码来源:test_model.py
示例12: test_to_json
def test_to_json(self):
""" Test the to_json function of Package. """
create_package(self.session)
package = model.Package.by_name(self.session, 'guake')
package = package.to_json()
self.assertEqual(package.keys(), ['status', 'upstream_url',
'name', 'summary', 'acls', 'creation_date',
'review_url'])
开发者ID:ralphbean,项目名称:packagedb2,代码行数:8,代码来源:test_package.py
示例13: test_packages_by_id
def test_packages_by_id(self):
""" Test the Packages.by_id function. """
create_project(self.session)
create_distro(self.session)
create_package(self.session)
pkg = model.Packages.by_id(self.session, 1)
self.assertEqual(pkg.package_name, 'geany')
self.assertEqual(pkg.distro, 'Fedora')
开发者ID:ncoghlan,项目名称:anitya,代码行数:9,代码来源:test_model.py
示例14: test_repr_package
def test_repr_package(self):
""" Test the __repr__ function of Package. """
create_package(self.session)
packages = model.Package.all(self.session)
self.assertEqual("Package(u'guake', u'Top down terminal for GNOME', "
"u'Approved', "
"upstreamurl=u'http://guake.org', "
"reviewurl=u'https://bugzilla.redhat.com/450189')",
packages[0].__repr__())
开发者ID:mizdebsk,项目名称:pkgdb2,代码行数:9,代码来源:test_package.py
示例15: test_add_tag
def test_add_tag(self):
""" Test the add_tag function of taggerlib. """
create_user(self.session)
user_pingou = model.FASUser.by_name(self.session, 'pingou')
user_ralph = model.FASUser.by_name(self.session, 'ralph')
create_package(self.session)
out = fedoratagger.lib.add_tag(self.session, 'guake', u'gnóme',
user_pingou)
self.assertEqual(out, u'Tag "gnóme" added to the package "guake"')
self.session.commit()
pkg = model.Package.by_name(self.session, 'guake')
self.assertEqual(1, len(pkg.tags))
self.assertEqual(u'gnóme', pkg.tags[0].label)
self.assertRaises(IntegrityError,
fedoratagger.lib.add_tag,
self.session, 'guake', u'gnóme', user_pingou)
self.session.rollback()
out = fedoratagger.lib.add_tag(self.session, 'guake', 'terminal',
user_pingou)
self.assertEqual(out, 'Tag "terminal" added to the package "guake"')
self.session.commit()
pkg = model.Package.by_name(self.session, 'guake')
self.assertEqual(2, len(pkg.tags))
self.assertEqual(u'gnóme', pkg.tags[0].label)
self.assertEqual('terminal', pkg.tags[1].label)
self.assertEqual(1, pkg.tags[0].like)
self.assertEqual(1, pkg.tags[1].like)
out = fedoratagger.lib.add_tag(self.session, 'guake', 'terminal',
user_ralph)
self.assertEqual(out, 'Tag "terminal" added to the package "guake"')
self.session.commit()
pkg = model.Package.by_name(self.session, 'guake')
self.assertEqual(2, len(pkg.tags))
self.assertEqual(u'gnóme', pkg.tags[0].label)
self.assertEqual('terminal', pkg.tags[1].label)
self.assertEqual(1, pkg.tags[0].like)
self.assertEqual(2, pkg.tags[1].like)
self.assertRaises(ValueError,
fedoratagger.lib.add_tag,
self.session, 'guake', 'ass',
user_pingou)
tagobj1 = model.Tag.get(self.session, pkg.id, 'terminal')
self.assertEquals('terminal on guake', tagobj1.__unicode__())
tagobj2 = model.Tag.get(self.session, pkg.id, u'gnóme')
self.assertEquals(u'gnóme on guake', tagobj2.__unicode__())
开发者ID:00willo,项目名称:fedora-tagger,代码行数:55,代码来源:test_taggerlib.py
示例16: test_admin_actions
def test_admin_actions(self, login_func):
""" Test the admin_actions function. """
login_func.return_value = None
user = FakeFasUserAdmin()
with user_set(pkgdb2.APP, user):
output = self.app.get('/admin/actions/')
self.assertEqual(output.status_code, 200)
self.assertTrue('<h1>Actions</h1>' in output.data)
self.assertTrue(
'Restrict to package: <input type="text" name="package" />'
in output.data)
output = self.app.get(
'/admin/actions/?page=abc&limit=def&status=ghi&package=test')
self.assertEqual(output.status_code, 200)
self.assertTrue('<h1>Actions</h1>' in output.data)
self.assertTrue(
'Restrict to package: <input type="text" name="package" />'
in output.data)
self.assertTrue(
'class="errors">Incorrect limit provided, using default</'
in output.data)
self.assertTrue(
'<li class="errors">No package exists</li>' in output.data)
output = self.app.get('/admin/actions/?package=guake')
self.assertEqual(output.status_code, 200)
self.assertTrue('<h1>Actions</h1>' in output.data)
self.assertTrue(
'Restrict to package: <input type="text" name="package" />'
in output.data)
self.assertTrue(
'<p>No actions found</p>' in output.data)
# Create some actions to see
create_collection(pkgdb2.SESSION)
create_package(pkgdb2.SESSION)
create_admin_actions(pkgdb2.SESSION, n=2)
# set the pagination
pkgdb2.APP.config['ITEMS_PER_PAGE'] = 1
# Check the list
output = self.app.get('/admin/actions/?status=all')
self.assertEqual(output.status_code, 200)
self.assertTrue('<h1>Actions</h1>' in output.data)
self.assertTrue(
'Restrict to package: <input type="text" name="package" />'
in output.data)
# 2 actions = 2 pages
self.assertTrue('<td>1 / 2</td>' in output.data)
# Reset the pagination
pkgdb2.APP.config['ITEMS_PER_PAGE'] = 50
开发者ID:TridevGuha,项目名称:pkgdb2,代码行数:55,代码来源:test_flask_ui_admin.py
示例17: test_api_get_project_distro
def test_api_get_project_distro(self):
""" Test the api_get_project_distro function of the API. """
create_distro(self.session)
output = self.app.get('/api/project/Fedora/geany')
self.assertEqual(output.status_code, 404)
data = json.loads(output.data)
exp = {
"error": "No package \"geany\" found in distro \"Fedora\"",
"output": "notok"
}
self.assertEqual(data, exp)
create_project(self.session)
create_package(self.session)
output = self.app.get('/api/project/Fedora/gnome-terminal/')
self.assertEqual(output.status_code, 404)
data = json.loads(output.data)
exp = {
"error": "No package \"gnome-terminal\" found in distro "
"\"Fedora\"",
"output": "notok"
}
self.assertEqual(data, exp)
output = self.app.get('/api/project/Fedora/geany/')
self.assertEqual(output.status_code, 200)
data = json.loads(output.data)
del(data['created_on'])
del(data['updated_on'])
exp = {
"id": 1,
"backend": "custom",
"homepage": "http://www.geany.org/",
"name": "geany",
"regex": 'DEFAULT',
"version": None,
"version_url": 'http://www.geany.org/Download/Releases',
"versions": [],
"packages": [
{
"distro": "Fedora",
"package_name": "geany"
}
],
}
self.assertEqual(data, exp)
开发者ID:Prashant-Surya,项目名称:anitya,代码行数:52,代码来源:test_flask_api.py
示例18: test_rating_dump
def test_rating_dump(self):
""" Test rating_pkg_dump """
output = self.app.get('/api/v1/rating/dump/')
self.assertEqual(output.status_code, 200)
self.assertEqual(output.data, '')
create_package(self.session)
create_rating(self.session)
output = self.app.get('/api/v1/rating/dump/')
self.assertEqual(output.status_code, 200)
self.assertEqual(output.data, 'guake\t75.0\n'
'geany\t100.0')
开发者ID:Swetha5,项目名称:fedora-tagger,代码行数:13,代码来源:test_flask_api.py
示例19: test_tag_dump
def test_tag_dump(self):
""" Test tag_pkg_dump """
output = self.app.get("/api/v1/tag/dump/")
self.assertEqual(output.status_code, 200)
self.assertEqual(output.data, "")
create_package(self.session)
create_tag(self.session)
output = self.app.get("/api/v1/tag/dump/")
self.assertEqual(output.status_code, 200)
self.assertEqual(
output.data.decode("utf-8"), u"guake\tgnóme\n" u"guake\tterminal\n" u"geany\tgnóme\ngeany\tide"
)
开发者ID:00willo,项目名称:fedora-tagger,代码行数:14,代码来源:test_flask_api.py
示例20: test_rating_dump
def test_rating_dump(self):
""" Test rating_pkg_dump """
output = self.app.get('/api/v1/rating/dump/')
self.assertEqual(output.status_code, 200)
self.assertEqual(output.data, '')
create_package(self.session)
create_rating(self.session)
set_usages(self.session, usage=True)
output = self.app.get('/api/v1/rating/dump/')
self.assertEqual(output.status_code, 200)
expected = 'guake\t75.0\t2\t2\ngeany\t100.0\t1\t1\ngitg\t-1.0\t0\t1'
self.assertEqual(output.data, expected)
开发者ID:bnprk,项目名称:fedora-tagger,代码行数:14,代码来源:test_flask_api.py
注:本文中的tests.create_package函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论