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


Python StagingAPI.set_review方法代码示例

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


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

示例1: TestApiCalls

# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import set_review [as 别名]

#.........这里部分代码省略.........

        # Get rq number
        num = self.api.get_request_id_for_package(prj, pkg)

        # Delete the package
        self.api.rm_from_prj(prj, request_id=num)

        # Verify package is not there
        self.assertTrue(full_name not in self.obs.links)

        # RQ is gone
        self.assertEqual(None, self.api.get_request_id_for_package(prj, pkg))
        self.assertEqual(None, self.api.get_package_for_request_id(prj, num))

        # Verify that review is closed
        self.assertEqual('accepted', self.obs.requests[str(num)]['review'])
        self.assertEqual('new', self.obs.requests[str(num)]['request'])

    def test_add_sr(self):
        prj = 'openSUSE:Factory:Staging:A'
        rq = '123'

        # Running it twice shouldn't change anything
        for i in range(2):
            # Add rq to the project
            self.api.rq_to_prj(rq, prj)
            # Verify that review is there
            self.assertEqual('new', self.obs.requests[rq]['review'])
            self.assertEqual('review', self.obs.requests[rq]['request'])
            self.assertEqual(self.api.get_prj_pseudometa('openSUSE:Factory:Staging:A'),
                             {'requests': [{'id': 123, 'package': 'gcc', 'author': 'Admin'}]})

    def test_create_package_container(self):
        """Test if the uploaded _meta is correct."""

        self.api.create_package_container('openSUSE:Factory:Staging:B', 'wine')
        self.assertEqual(httpretty.last_request().method, 'PUT')
        self.assertEqual(httpretty.last_request().body, '<package name="wine"><title/><description/></package>')
        self.assertEqual(httpretty.last_request().path, '/source/openSUSE:Factory:Staging:B/wine/_meta')

        self.api.create_package_container('openSUSE:Factory:Staging:B', 'wine', disable_build=True)
        self.assertEqual(httpretty.last_request().method, 'PUT')
        self.assertEqual(httpretty.last_request().body, '<package name="wine"><title /><description /><build><disable /></build></package>')
        self.assertEqual(httpretty.last_request().path, '/source/openSUSE:Factory:Staging:B/wine/_meta')

    def test_review_handling(self):
        """Test whether accepting/creating reviews behaves correctly."""

        # Add review
        self.api.add_review('123', by_project='openSUSE:Factory:Staging:A')
        self.assertEqual(httpretty.last_request().method, 'POST')
        self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'addreview'])
        # Try to readd, should do anything
        self.api.add_review('123', by_project='openSUSE:Factory:Staging:A')
        self.assertEqual(httpretty.last_request().method, 'GET')
        # Accept review
        self.api.set_review('123', 'openSUSE:Factory:Staging:A')
        self.assertEqual(httpretty.last_request().method, 'POST')
        self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'changereviewstate'])
        # Try to accept it again should do anything
        self.api.set_review('123', 'openSUSE:Factory:Staging:A')
        self.assertEqual(httpretty.last_request().method, 'GET')
        # But we should be able to reopen it
        self.api.add_review('123', by_project='openSUSE:Factory:Staging:A')
        self.assertEqual(httpretty.last_request().method, 'POST')
        self.assertEqual(httpretty.last_request().querystring[u'cmd'], [u'addreview'])

    def test_prj_from_letter(self):

        # Verify it works
        self.assertEqual(self.api.prj_from_letter('openSUSE:Factory'), 'openSUSE:Factory')
        self.assertEqual(self.api.prj_from_letter('A'), 'openSUSE:Factory:Staging:A')

    def test_frozen_mtime(self):
        """Test frozen mtime."""

        # Testing frozen mtime
        self.assertTrue(self.api.days_since_last_freeze('openSUSE:Factory:Staging:A') > 8)
        self.assertTrue(self.api.days_since_last_freeze('openSUSE:Factory:Staging:B') < 1)

        # U == unfrozen
        self.assertTrue(self.api.days_since_last_freeze('openSUSE:Factory:Staging:U') > 1000)

    def test_frozen_enough(self):
        """Test frozen enough."""

        # Testing frozen mtime
        self.assertEqual(self.api.prj_frozen_enough('openSUSE:Factory:Staging:B'), True)
        self.assertEqual(self.api.prj_frozen_enough('openSUSE:Factory:Staging:A'), False)

        # U == unfrozen
        self.assertEqual(self.api.prj_frozen_enough('openSUSE:Factory:Staging:U'), False)

    def test_move(self):
        """Test package movement."""

        init_data = self.api.get_package_information('openSUSE:Factory:Staging:B', 'wine')
        self.api.move_between_project('openSUSE:Factory:Staging:B', 333, 'openSUSE:Factory:Staging:A')
        test_data = self.api.get_package_information('openSUSE:Factory:Staging:A', 'wine')
        self.assertEqual(init_data, test_data)
开发者ID:coogor,项目名称:osc-plugin-factory,代码行数:104,代码来源:api_tests.py

示例2: TestApiCalls

# 需要导入模块: from osclib.stagingapi import StagingAPI [as 别名]
# 或者: from osclib.stagingapi.StagingAPI import set_review [as 别名]

#.........这里部分代码省略.........
        self.api.rm_from_prj(prj, request_id=num)

        # Verify package is not there
        self.assertTrue(full_name not in self.obs.links)

        # RQ is gone
        self.assertEqual(None, self.api.get_request_id_for_package(prj, pkg))
        self.assertEqual(None, self.api.get_package_for_request_id(prj, num))

        # Verify that review is closed
        self.assertEqual("accepted", self.obs.requests[str(num)]["review"])
        self.assertEqual("new", self.obs.requests[str(num)]["request"])

    def test_add_sr(self):
        prj = "openSUSE:Factory:Staging:A"
        rq = "123"

        # Running it twice shouldn't change anything
        for i in range(2):
            # Add rq to the project
            self.api.rq_to_prj(rq, prj)
            # Verify that review is there
            self.assertEqual("new", self.obs.requests[rq]["review"])
            self.assertEqual("review", self.obs.requests[rq]["request"])
            self.assertEqual(
                self.api.get_prj_pseudometa("openSUSE:Factory:Staging:A"),
                {"requests": [{"id": 123, "package": "gcc", "author": "Admin"}]},
            )

    def test_create_package_container(self):
        """Test if the uploaded _meta is correct."""

        self.api.create_package_container("openSUSE:Factory:Staging:B", "wine")
        self.assertEqual(httpretty.last_request().method, "PUT")
        self.assertEqual(httpretty.last_request().body, '<package name="wine"><title/><description/></package>')
        self.assertEqual(httpretty.last_request().path, "/source/openSUSE:Factory:Staging:B/wine/_meta")

        self.api.create_package_container("openSUSE:Factory:Staging:B", "wine", disable_build=True)
        self.assertEqual(httpretty.last_request().method, "PUT")
        self.assertEqual(
            httpretty.last_request().body,
            '<package name="wine"><title /><description /><build><disable /></build></package>',
        )
        self.assertEqual(httpretty.last_request().path, "/source/openSUSE:Factory:Staging:B/wine/_meta")

    def test_review_handling(self):
        """Test whether accepting/creating reviews behaves correctly."""

        # Add review
        self.api.add_review("123", by_project="openSUSE:Factory:Staging:A")
        self.assertEqual(httpretty.last_request().method, "POST")
        self.assertEqual(httpretty.last_request().querystring[u"cmd"], [u"addreview"])
        # Try to readd, should do anything
        self.api.add_review("123", by_project="openSUSE:Factory:Staging:A")
        self.assertEqual(httpretty.last_request().method, "GET")
        # Accept review
        self.api.set_review("123", "openSUSE:Factory:Staging:A")
        self.assertEqual(httpretty.last_request().method, "POST")
        self.assertEqual(httpretty.last_request().querystring[u"cmd"], [u"changereviewstate"])
        # Try to accept it again should do anything
        self.api.set_review("123", "openSUSE:Factory:Staging:A")
        self.assertEqual(httpretty.last_request().method, "GET")
        # But we should be able to reopen it
        self.api.add_review("123", by_project="openSUSE:Factory:Staging:A")
        self.assertEqual(httpretty.last_request().method, "POST")
        self.assertEqual(httpretty.last_request().querystring[u"cmd"], [u"addreview"])

    def test_prj_from_letter(self):

        # Verify it works
        self.assertEqual(self.api.prj_from_letter("openSUSE:Factory"), "openSUSE:Factory")
        self.assertEqual(self.api.prj_from_letter("A"), "openSUSE:Factory:Staging:A")

    def test_frozen_mtime(self):
        """Test frozen mtime."""

        # Testing frozen mtime
        self.assertTrue(self.api.days_since_last_freeze("openSUSE:Factory:Staging:A") > 8)
        self.assertTrue(self.api.days_since_last_freeze("openSUSE:Factory:Staging:B") < 1)

        # U == unfrozen
        self.assertTrue(self.api.days_since_last_freeze("openSUSE:Factory:Staging:U") > 1000)

    def test_frozen_enough(self):
        """Test frozen enough."""

        # Testing frozen mtime
        self.assertEqual(self.api.prj_frozen_enough("openSUSE:Factory:Staging:B"), True)
        self.assertEqual(self.api.prj_frozen_enough("openSUSE:Factory:Staging:A"), False)

        # U == unfrozen
        self.assertEqual(self.api.prj_frozen_enough("openSUSE:Factory:Staging:U"), False)

    def test_move(self):
        """Test package movement."""

        init_data = self.api.get_package_information("openSUSE:Factory:Staging:B", "wine")
        self.api.move_between_project("openSUSE:Factory:Staging:B", 333, "openSUSE:Factory:Staging:A")
        test_data = self.api.get_package_information("openSUSE:Factory:Staging:A", "wine")
        self.assertEqual(init_data, test_data)
开发者ID:bluca,项目名称:osc-plugin-factory,代码行数:104,代码来源:api_tests.py


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