Пример #1
0
    def setUp(self):
        self.working_dir = tempfile.mkdtemp()

        # Because uh, QSettings has very nice API so we need this
        QSettings.setDefaultFormat(QSettings.Format.IniFormat)

        # and this line, which include
        QSettings.setPath(
            QSettings.Format.IniFormat,  # this arg
            QSettings.Scope.SystemScope,
            self.working_dir,
        )

        # to have our test settings isolated from the real application.
        # Insert profanity here: ________________

        # now we make our info
        info = PMR()

        self.endpoints = [
            (info.host() + '/pmr2-dashboard',
             TestAdapter(stream=workspace_home)),
            ('http://example.com/dashboard/addworkspace',
             TestAdapter(stream='',
                         headers={
                             'Location': 'http://example.com/w/+/addworkspace',
                         })),
            (
                'http://example.com/w/+/addworkspace',
                TestAdapter(
                    # XXX need to make this a real thing when we test that
                    # responses from server matters.
                    stream='',
                    headers={
                        'Location': 'http://example.com/w/1',
                    })),
            (
                'http://example.com/hgrepo',
                TestAdapter(
                    # XXX need to make this a real thing when we test that
                    # responses from server matters.
                    stream='{"url": "http://example.com/hgrepo", '
                    '"storage": "git"}', )),
            (
                'http://example.com/w/1',
                TestAdapter(
                    # XXX need to make this a real thing when we test that
                    # responses from server matters.
                    stream='{"url": "http://example.com/w/1", '
                    '"storage": "git"}', )),
            ('http://example.com/w/1/request_temporary_password',
             TestAdapter(stream='{"user": "******", "key": "secret"}', )),
            (info.host() + '/search',
             TestAdapter(stream='[{"title": "Test Workspace", '
                         '"target": "http://example.com/w/1"}]', )),
        ]

        # and tool, with the end points.
        self._tool = self.make_tool()
    def testPMR(self):
        info = PMR()
        host = info.host()

        self.assertIsInstance(host, unicode)

        self.assertTrue(info.addHost('garbage'))
        self.assertIn('garbage', info._instances)

        self.assertFalse(info.setActiveHost('rubbish'))
        self.assertTrue(info.setActiveHost('garbage'))


        self.assertTrue(info.removeHost('garbage'))
        self.assertTrue(info.host() is None)
        self.assertFalse(info.removeHost('garbage'))
Пример #3
0
 def test_search_failure(self):
     info = PMR()
     tool = self.make_tool(endpoints=[
         (info.host() + '/search',
          TestAdapter(stream='Invalid', status=403)),
     ])
     # the private method exposes exceptions
     self.assertRaises(HTTPError, tool._search, '')
     # the real method traps all exceptions
     self.assertRaises(PMRToolError, tool.search, '')
    def __init__(self, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self._ui = Ui_AuthoriseApplicationDialog()
        self._ui.setupUi(self)

        pmr_info = PMR()
        client_tokens = pmr_info.get_client_token_kwargs()
        self._helper = TokenHelper(
            client_key=client_tokens['client_key'],
            client_secret=client_tokens['client_secret'],
            site_url=pmr_info.host(),
        )