本文整理汇总了Python中osclib.stagingapi.StagingAPI.set_prj_pseudometa方法的典型用法代码示例。如果您正苦于以下问题:Python StagingAPI.set_prj_pseudometa方法的具体用法?Python StagingAPI.set_prj_pseudometa怎么用?Python StagingAPI.set_prj_pseudometa使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osclib.stagingapi.StagingAPI
的用法示例。
在下文中一共展示了StagingAPI.set_prj_pseudometa方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestApiCalls
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import set_prj_pseudometa [as 别名]
class TestApiCalls(unittest.TestCase):
"""
Tests for various api calls to ensure we return expected content
"""
def setUp(self):
"""
Initialize the configuration
"""
self.obs = OBS()
Config('openSUSE:Factory')
self.api = StagingAPI(APIURL, 'openSUSE:Factory')
def tearDown(self):
"""Clean internal cache"""
if hasattr(self.api, '_invalidate_all'):
self.api._invalidate_all()
def test_ring_packages(self):
"""
Validate the creation of the rings.
"""
# our content in the XML files
# test content for listonly ie. list command
ring_packages = {
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
'elem-ring-1': 'openSUSE:Factory:Rings:0-Bootstrap',
'elem-ring-mini': 'openSUSE:Factory:Rings:0-Bootstrap',
'elem-ring-2': 'openSUSE:Factory:Rings:2-TestDVD',
'git': 'openSUSE:Factory:Rings:2-TestDVD',
'wine': 'openSUSE:Factory:Rings:1-MinimalX',
}
self.assertEqual(ring_packages, self.api.ring_packages_for_links)
# test content for real usage
ring_packages = {
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX',
'elem-ring-mini': 'openSUSE:Factory:Rings:0-Bootstrap',
'elem-ring-2': 'openSUSE:Factory:Rings:2-TestDVD',
'git': 'openSUSE:Factory:Rings:2-TestDVD',
'wine': 'openSUSE:Factory:Rings:1-MinimalX',
}
self.assertEqual(ring_packages, self.api.ring_packages)
@unittest.skip("no longer approving non-ring packages")
def test_dispatch_open_requests(self):
"""
Test dispatching and closure of non-ring packages
"""
# Get rid of open requests
self.api.dispatch_open_requests()
# Check that we tried to close it
self.assertEqual(httpretty.last_request().method, 'POST')
self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'changereviewstate'])
# Try it again
self.api.dispatch_open_requests()
# This time there should be nothing to close
self.assertEqual(httpretty.last_request().method, 'GET')
def test_pseudometa_get_prj(self):
"""
Test getting project metadata from YAML in project description
"""
# Try to get data from project that has no metadata
data = self.api.get_prj_pseudometa('openSUSE:Factory:Staging:A')
# Should be empty, but contain structure to work with
self.assertEqual(data, {'requests': []})
# Add some sample data
rq = {'id': '123', 'package': 'test-package'}
data['requests'].append(rq)
# Save them and read them back
self.api.set_prj_pseudometa('openSUSE:Factory:Staging:A', data)
test_data = self.api.get_prj_pseudometa('openSUSE:Factory:Staging:A')
# Verify that we got back the same data
self.assertEqual(data, test_data)
def test_list_projects(self):
"""
List projects and their content
"""
# Prepare expected results
data = []
for prj in self.obs.staging_project:
data.append('openSUSE:Factory:Staging:' + prj)
# Compare the results
self.assertEqual(data, self.api.get_staging_projects())
def test_open_requests(self):
"""
Test searching for open requests
"""
requests = []
#.........这里部分代码省略.........
示例2: TestApiCalls
# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import set_prj_pseudometa [as 别名]
class TestApiCalls(unittest.TestCase):
"""
Tests for various api calls to ensure we return expected content
"""
def setUp(self):
"""
Initialize the configuration
"""
self.obs = OBS()
Config("openSUSE:Factory")
self.api = StagingAPI(APIURL, "openSUSE:Factory")
def tearDown(self):
"""Clean internal cache"""
self.api._invalidate_all()
def test_ring_packages(self):
"""
Validate the creation of the rings.
"""
# our content in the XML files
ring_packages = {
"elem-ring-0": "openSUSE:Factory:Rings:0-Bootstrap",
"elem-ring-1": "openSUSE:Factory:Rings:1-MinimalX",
"elem-ring-2": "openSUSE:Factory:Rings:2-TestDVD",
"git": "openSUSE:Factory:Rings:2-TestDVD",
"wine": "openSUSE:Factory:Rings:1-MinimalX",
}
self.assertEqual(ring_packages, self.api.ring_packages)
@unittest.skip("no longer approving non-ring packages")
def test_dispatch_open_requests(self):
"""
Test dispatching and closure of non-ring packages
"""
# Get rid of open requests
self.api.dispatch_open_requests()
# Check that we tried to close it
self.assertEqual(httpretty.last_request().method, "POST")
self.assertEqual(httpretty.last_request().querystring[u"cmd"], [u"changereviewstate"])
# Try it again
self.api.dispatch_open_requests()
# This time there should be nothing to close
self.assertEqual(httpretty.last_request().method, "GET")
def test_pseudometa_get_prj(self):
"""
Test getting project metadata from YAML in project description
"""
# Try to get data from project that has no metadata
data = self.api.get_prj_pseudometa("openSUSE:Factory:Staging:A")
# Should be empty, but contain structure to work with
self.assertEqual(data, {"requests": []})
# Add some sample data
rq = {"id": "123", "package": "test-package"}
data["requests"].append(rq)
# Save them and read them back
self.api.set_prj_pseudometa("openSUSE:Factory:Staging:A", data)
test_data = self.api.get_prj_pseudometa("openSUSE:Factory:Staging:A")
# Verify that we got back the same data
self.assertEqual(data, test_data)
def test_list_projects(self):
"""
List projects and their content
"""
# Prepare expected results
data = []
for prj in self.obs.staging_project:
data.append("openSUSE:Factory:Staging:" + prj)
# Compare the results
self.assertEqual(data, self.api.get_staging_projects())
def test_open_requests(self):
"""
Test searching for open requests
"""
requests = []
# get the open requests
requests = self.api.get_open_requests()
# Compare the results, we only care now that we got 1 of them not the content
self.assertEqual(1, len(requests))
def test_get_package_information(self):
"""
Test if we get proper project, name and revision from the staging informations
"""
package_info = {
"dir_srcmd5": "751efeae52d6c99de48164088a33d855",
"project": "home:Admin",
#.........这里部分代码省略.........