예제 #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