Exemplo n.º 1
0
 def test_run_http_exc_raise_unknown_error(self, mock_get):
     url = 'http://gerrit.example.com'
     try:
         cmd.run_http_exc(FakeException, url)
         self.fails('Exception expected')
     except FakeException as err:
         self.assertEqual(255, err.code)
         mock_get.assert_called_once_with(url)
Exemplo n.º 2
0
 def test_run_http_exc_raise_unknown_error(self, mock_get):
     url = 'http://gerrit.example.com'
     try:
         cmd.run_http_exc(FakeException, url)
         self.fails('Exception expected')
     except FakeException as err:
         self.assertEqual(255, err.code)
         mock_get.assert_called_once_with(url)
Exemplo n.º 3
0
    def test_run_http_exc_with_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        cmd.run_http_exc(FakeException, url)
        mock_run.assert_called_once_with(mock.ANY, 'git', 'credential', 'fill',
                                         stdin='url=%s' % url)
        calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
        mock_get.assert_has_calls(calls)
Exemplo n.º 4
0
    def test_run_http_exc_with_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        cmd.run_http_exc(FakeException, url)
        # This gets encoded to utf8 which means the type passed down
        # is bytes.
        mock_run.assert_called_once_with('git', 'credential', 'fill',
                                         stdin=b'url=%s' % url.encode('utf-8'))
        calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
        mock_get.assert_has_calls(calls)
Exemplo n.º 5
0
    def test_run_http_exc_with_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        cmd.run_http_exc(FakeException, url)
        mock_run.assert_called_once_with('git',
                                         'credential',
                                         'fill',
                                         stdin='url=%s' % url)
        calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
        mock_get.assert_has_calls(calls)
Exemplo n.º 6
0
    def test_run_http_exc_with_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        cmd.run_http_exc(FakeException, url)
        # This gets encoded to utf8 which means the type passed down
        # is bytes.
        mock_run.assert_called_once_with('git', 'credential', 'fill',
                                         stdin=b'url=%s' % url.encode('utf-8'))
        calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
        mock_get.assert_has_calls(calls)
Exemplo n.º 7
0
    def test_run_http_exc_with_failing_git_creds(self, mock_get, mock_run):
        url = 'http://[email protected]'

        try:
            cmd.run_http_exc(FakeException, url)
            self.fails('Exception expected')
        except FakeException as err:
            self.assertEqual(cmd.http_code_2_return_code(401), err.code)
        mock_run.assert_called_once_with('git', 'credential', 'fill',
                                         stdin='url=%s' % url)
        mock_get.assert_called_once_with(url)
Exemplo n.º 8
0
    def test_run_http_exc_with_failing_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        try:
            cmd.run_http_exc(FakeException, url)
            self.fails('Exception expected')
        except FakeException as err:
            self.assertEqual(cmd.http_code_2_return_code(401), err.code)
        mock_run.assert_called_once_with(mock.ANY, 'git', 'credential', 'fill',
                                         stdin='url=%s' % url)
        calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
        mock_get.assert_has_calls(calls)
Exemplo n.º 9
0
    def test_run_http_exc_with_failing_git_creds(self, mock_get, mock_run):
        url = 'http://[email protected]'

        try:
            cmd.run_http_exc(FakeException, url)
            self.fails('Exception expected')
        except FakeException as err:
            self.assertEqual(cmd.http_code_2_return_code(401), err.code)
        mock_run.assert_called_once_with('git',
                                         'credential',
                                         'fill',
                                         stdin='url=%s' % url)
        mock_get.assert_called_once_with(url)
Exemplo n.º 10
0
    def test_run_http_exc_with_failing_git_creds(self, mock_get, mock_run):
        url = 'http://[email protected]'

        try:
            cmd.run_http_exc(FakeException, url)
            self.fails('Exception expected')
        except FakeException as err:
            self.assertEqual(cmd.http_code_2_return_code(401), err.code)
        # This gets encoded to utf8 which means the type passed down
        # is bytes.
        mock_run.assert_called_once_with('git', 'credential', 'fill',
                                         stdin=b'url=%s' % url.encode('utf-8'))
        mock_get.assert_called_once_with(url)
Exemplo n.º 11
0
    def test_run_http_exc_with_failing_git_creds(self, mock_get, mock_run):
        url = 'http://[email protected]'

        try:
            cmd.run_http_exc(FakeException, url)
            self.fails('Exception expected')
        except FakeException as err:
            self.assertEqual(cmd.http_code_2_return_code(401), err.code)
        # This gets encoded to utf8 which means the type passed down
        # is bytes.
        mock_run.assert_called_once_with('git', 'credential', 'fill',
                                         stdin=b'url=%s' % url.encode('utf-8'))
        mock_get.assert_called_once_with(url)
Exemplo n.º 12
0
    def test_run_http_exc_with_failing_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        try:
            cmd.run_http_exc(FakeException, url)
            self.fails('Exception expected')
        except FakeException as err:
            self.assertEqual(cmd.http_code_2_return_code(401), err.code)
        mock_run.assert_called_once_with(mock.ANY,
                                         'git',
                                         'credential',
                                         'fill',
                                         stdin='url=%s' % url)
        calls = [mock.call(url), mock.call(url, auth=('user', 'pass'))]
        mock_get.assert_has_calls(calls)
Exemplo n.º 13
0
    def test_run_http_exc_without_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        cmd.run_http_exc(FakeException, url)
        self.assertFalse(mock_run.called)
        mock_get.assert_called_once_with(url)
Exemplo n.º 14
0
    def test_run_http_exc_without_auth(self, mock_get, mock_run):
        url = 'http://[email protected]'

        cmd.run_http_exc(FakeException, url)
        self.assertFalse(mock_run.called)
        mock_get.assert_called_once_with(url)