# Path: modernrpc/exceptions.py
# RPC_METHOD_NOT_FOUND = -32601
# 
# RPC_INVALID_PARAMS = -32602
# 
# RPC_INTERNAL_ERROR = -32603
# 
# RPC_INVALID_REQUEST = -32600
# 
# RPC_PARSE_ERROR = -32700
# 
# RPC_CUSTOM_ERROR_BASE = -32099


import json
import random
import re
import xml.etree.cElementTree as ET
import pytest
import requests
from json import JSONDecodeError
from django.core.serializers.json import DjangoJSONEncoder
from modernrpc.exceptions import (
    RPC_METHOD_NOT_FOUND,
    RPC_INVALID_PARAMS,
    RPC_INTERNAL_ERROR,
    RPC_INVALID_REQUEST,
    RPC_PARSE_ERROR,
    RPC_CUSTOM_ERROR_BASE,
)
        )
        assert code == RPC_INVALID_REQUEST

    def test_incomplete_payload(self, live_server, endpoint_path):
        invalid_payload = """<?xml version="1.0"?>
<methodCall>
</methodCall>"""
        code, message = self.low_level_xmlrpc_call(
            live_server.url + endpoint_path, payload=invalid_payload
        )

        assert "Invalid request: The request appear to be invalid." == message
        assert code == RPC_INVALID_REQUEST

    def test_invalid_payload(self, live_server, endpoint_path):
        # "</methodName" misses the closing '>'
        invalid_payload = """<?xml version="1.0"?>
    <methodCall>
      <methodName>examples.getStateName</methodName
      <params>
         <param>
            <value><double>2.41</double></value>
         </param>
      </params>
    </methodCall>"""
        code, message = self.low_level_xmlrpc_call(
            live_server.url + endpoint_path, payload=invalid_payload
        )

        assert "not well-formed" in message

# Path: modernrpc/exceptions.py
# RPC_METHOD_NOT_FOUND = -32601
# 
# RPC_INVALID_PARAMS = -32602
# 
# RPC_INTERNAL_ERROR = -32603
# 
# RPC_INVALID_REQUEST = -32600
# 
# RPC_PARSE_ERROR = -32700
# 
# RPC_CUSTOM_ERROR_BASE = -32099


# Path: tests/functional/test_errors.py
import json
import random
import re
import xml.etree.cElementTree as ET
import pytest
import requests
from json import JSONDecodeError
from django.core.serializers.json import DjangoJSONEncoder
from modernrpc.exceptions import (
    RPC_METHOD_NOT_FOUND,
    RPC_INVALID_PARAMS,
    RPC_INTERNAL_ERROR,
    RPC_INVALID_REQUEST,
    RPC_PARSE_ERROR,
    RPC_CUSTOM_ERROR_BASE,
)

        )
        assert code == RPC_INVALID_REQUEST

    def test_incomplete_payload(self, live_server, endpoint_path):
        invalid_payload = """<?xml version="1.0"?>
<methodCall>
</methodCall>"""
        code, message = self.low_level_xmlrpc_call(
            live_server.url + endpoint_path, payload=invalid_payload
        )

        assert "Invalid request: The request appear to be invalid." == message
        assert code == RPC_INVALID_REQUEST

    def test_invalid_payload(self, live_server, endpoint_path):
        # "</methodName" misses the closing '>'
        invalid_payload = """<?xml version="1.0"?>
    <methodCall>
      <methodName>examples.getStateName</methodName
      <params>
         <param>
            <value><double>2.41</double></value>
         </param>
      </params>
    </methodCall>"""
        code, message = self.low_level_xmlrpc_call(
            live_server.url + endpoint_path, payload=invalid_payload
        )

        assert "not well-formed" in message

        assert code == RPC_PARSE_ERROR