File: fakes.py

package info (click to toggle)
python-restless 2.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 608 kB
  • sloc: python: 2,124; makefile: 148
file content (24 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import six


class FakeHttpRequest(object):
    def __init__(self, method='GET', body='', **kwargs):
        self.method = method.upper()
        self.body = body
        if six.PY3:
            self.body = body.encode('utf-8')
        if self.method == 'GET':
            self.GET = kwargs.get('get_request', {})


class FakeHttpResponse(object):
    def __init__(self, body, content_type='text/html'):
        self.body = body
        self.content_type = content_type
        self.status_code = 200


class FakeModel(object):
    def __init__(self, **kwargs):
        for k, v in kwargs.items():
            setattr(self, k, v)