Beispiel #1
0
 def test_get_session__from_credentials_file(self, mock_path, mock_open,
                                             mock_is_starred):
     mock_path.expanduser.return_value = 'mock_path'
     mock_path.isfile.return_value = True
     mock_open.return_value = MagicMock(spec=IOBase)
     self.assertTrue(helpers.get_session())
     self.assertTrue(mock_is_starred.called)
Beispiel #2
0
 def test_get_session__from_credentials_file(self, mock_path, mock_open,
                                             mock_is_starred):
     mock_path.expanduser.return_value = 'mock_path'
     mock_path.isfile.return_value = True
     mock_open.return_value = MagicMock(spec=IOBase)
     self.assertTrue(helpers.get_session())
     self.assertTrue(mock_is_starred.called)
Beispiel #3
0
 def test_get_session__authenticate(self, mock_path, mock_prompt,
                                    mock_getpass, mock_authorize,
                                    mock_open):
     mock_path.isfile.return_value = False
     self.assertTrue(isinstance(helpers.get_session(), GitHub))
     self.assertTrue(mock_prompt.called)
     self.assertTrue(mock_getpass.called)
     self.assertTrue(mock_open.called)
Beispiel #4
0
 def test_get_session__authenticate(self, mock_path, mock_prompt,
                                    mock_getpass, mock_authorize,
                                    mock_open):
     mock_path.isfile.return_value = False
     self.assertTrue(isinstance(helpers.get_session(), GitHub))
     self.assertTrue(mock_prompt.called)
     self.assertTrue(mock_getpass.called)
     self.assertTrue(mock_open.called)
Beispiel #5
0
    def test_get_session__from_credentials_file__handled_exception(
            self, mock_path, mock_open, mock_is_starred, mock_stderr,
            mock_prompt, mock_getpass, mock_authorize):
        mock_path.expanduser.return_value = 'mock_path'
        mock_path.isfile.return_value = True
        mock_open.return_value = MagicMock(spec=IOBase)

        mock_response = MockResponse(content='', status_code=401)
        mock_is_starred.side_effect = GitHubError(mock_response)
        self.assertTrue(isinstance(helpers.get_session(), GitHub))
        self.assertTrue(mock_stderr.write.called)
        self.assertTrue(mock_prompt.called)
        self.assertTrue(mock_getpass.called)
        self.assertTrue(mock_open.called)
Beispiel #6
0
    def test_get_session__from_credentials_file__handled_exception(
            self, mock_path, mock_open, mock_is_starred, mock_stderr,
            mock_prompt, mock_getpass, mock_authorize):
        mock_path.expanduser.return_value = 'mock_path'
        mock_path.isfile.return_value = True
        mock_open.return_value = MagicMock(spec=IOBase)

        mock_response = MockResponse(content='', status_code=401)
        mock_is_starred.side_effect = GitHubError(mock_response)
        self.assertTrue(isinstance(helpers.get_session(), GitHub))
        self.assertTrue(mock_stderr.write.called)
        self.assertTrue(mock_prompt.called)
        self.assertTrue(mock_getpass.called)
        self.assertTrue(mock_open.called)