import json

from go.dashboard import DiamondashApiError, DiamondashApiClient


class FakeDiamondashApiClient(DiamondashApiClient):
    def __init__(self):
        self.requests = []
        self.response = None

    def get_requests(self):
        return self.requests

    def set_error_response(self, code, message):
        data = json.dumps({
            'success': False,
            'message': message
        })

        self.response = DiamondashApiError("(%s) %s" % (code, data))

    def set_response(self, response):
        self.response = response

    def request(self, method, url, data):
        self.requests.append({
            'method': method,
            'url': url,
            'data': data,
        })

        if isinstance(self.response, Exception):
            raise self.response

        return self.response

import json

from go.dashboard import DiamondashApiError, DiamondashApiClient


class FakeDiamondashApiClient(DiamondashApiClient):
    def __init__(self):
        self.requests = []
        self._response = None

    @property
    def response(self):
        if isinstance(self._response, Exception):
            raise self._response

        return self._response

    def set_error_response(self, code, message):
        data = json.dumps({
            'success': False,
            'message': message
        })

        self._response = DiamondashApiError("(%s) %s" % (code, data))

    def set_response(self, response):
        self._response = response

    def get_requests(self):
        return self.requests

    def request(self, method, url, data):
        self.requests.append({
            'method': method,
            'url': url,
            'data': data,
        })

        return self.response

    def raw_request(self, method, url, content=""):
        self.requests.append({
            'method': method,
            'url': url,
            'content': content,
        })

        return self.response

Add raw_request method for FakeDiamondashApiClient to correspond to the recently added DiamondashApiClient.raw_request()
Add raw_request method for FakeDiamondashApiClient to correspond to the recently added DiamondashApiClient.raw_request()

  import json
  
  from go.dashboard import DiamondashApiError, DiamondashApiClient
  
  
  class FakeDiamondashApiClient(DiamondashApiClient):
      def __init__(self):
          self.requests = []
-         self.response = None
+         self._response = None
  
-     def get_requests(self):
+     @property
+     def response(self):
+         if isinstance(self._response, Exception):
+             raise self._response
+ 
-         return self.requests
+         return self._response
  
      def set_error_response(self, code, message):
          data = json.dumps({
              'success': False,
              'message': message
          })
  
-         self.response = DiamondashApiError("(%s) %s" % (code, data))
+         self._response = DiamondashApiError("(%s) %s" % (code, data))
  
      def set_response(self, response):
-         self.response = response
+         self._response = response
+ 
+     def get_requests(self):
+         return self.requests
  
      def request(self, method, url, data):
          self.requests.append({
              'method': method,
              'url': url,
              'data': data,
          })
  
-         if isinstance(self.response, Exception):
-             raise self.response
+         return self.response
+ 
+     def raw_request(self, method, url, content=""):
+         self.requests.append({
+             'method': method,
+             'url': url,
+             'content': content,
+         })
  
          return self.response
  
Add raw_request method for FakeDiamondashApiClient to correspond to the recently added DiamondashApiClient.raw_request()
## Code Before:
import json

from go.dashboard import DiamondashApiError, DiamondashApiClient


class FakeDiamondashApiClient(DiamondashApiClient):
    def __init__(self):
        self.requests = []
        self.response = None

    def get_requests(self):
        return self.requests

    def set_error_response(self, code, message):
        data = json.dumps({
            'success': False,
            'message': message
        })

        self.response = DiamondashApiError("(%s) %s" % (code, data))

    def set_response(self, response):
        self.response = response

    def request(self, method, url, data):
        self.requests.append({
            'method': method,
            'url': url,
            'data': data,
        })

        if isinstance(self.response, Exception):
            raise self.response

        return self.response

## Instruction:
Add raw_request method for FakeDiamondashApiClient to correspond to the recently added DiamondashApiClient.raw_request()
## Code After:
import json

from go.dashboard import DiamondashApiError, DiamondashApiClient


class FakeDiamondashApiClient(DiamondashApiClient):
    def __init__(self):
        self.requests = []
        self._response = None

    @property
    def response(self):
        if isinstance(self._response, Exception):
            raise self._response

        return self._response

    def set_error_response(self, code, message):
        data = json.dumps({
            'success': False,
            'message': message
        })

        self._response = DiamondashApiError("(%s) %s" % (code, data))

    def set_response(self, response):
        self._response = response

    def get_requests(self):
        return self.requests

    def request(self, method, url, data):
        self.requests.append({
            'method': method,
            'url': url,
            'data': data,
        })

        return self.response

    def raw_request(self, method, url, content=""):
        self.requests.append({
            'method': method,
            'url': url,
            'content': content,
        })

        return self.response
