本文整理汇总了Python中tests.create_package函数的典型用法代码示例。如果您正苦于以下问题:Python create_package函数的具体用法?Python create_package怎么用?Python create_package使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_package函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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'])
示例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)
示例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)
示例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)
示例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')
示例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')
示例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)
示例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)
示例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'])
示例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)>')
示例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'])
示例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')
示例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__())
示例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__())