Пример #1
0
    def test_msg_message(self):
        mock_res = mock.Mock()
        mock_res.json.return_value = {
            'message': 'this is a fake response message'
        }

        expected_result = 'this is a fake response message'
        self.assertEqual(_msg(mock_res), expected_result)
Пример #2
0
def test_msg_msg():
    mock_res = mock.Mock()
    mock_res.json.return_value = {
        'msg': 'this is a fake response message'
    }

    expected_result = 'this is a fake response message'
    assert _msg(mock_res) == expected_result
Пример #3
0
    def test_msg_errors(self):
        mock_res = mock.Mock()
        mock_res.json.return_value = {
            'errors': [{
                'message': 'this is a fake requests error',
                'code': 400
            }]
        }

        expected_result = 'this is a fake requests error'
        self.assertEqual(_msg(mock_res), expected_result)
Пример #4
0
 def test_msg_exception_no_text(self):
     mock_res = mock.Mock()
     mock_res.json.return_value = ValueError('fake value error')
     mock_res.text = ''
     expected_result = 'Something went wrong'
     self.assertEqual(_msg(mock_res), expected_result)
Пример #5
0
    def test_msg_exception_text(self):
        mock_res = mock.Mock(return_value=ValueError('fake value error'))
        mock_res.text = 'this is a fake response text'

        expected_result = 'this is a fake response text'
        self.assertEqual(_msg(mock_res), expected_result)
Пример #6
0
def test_msg_exception_text():
    mock_res = mock.Mock(return_value=ValueError('fake value error'))
    mock_res.text = 'this is a fake response text'

    expected_result = 'this is a fake response text'
    assert _msg(mock_res) == expected_result