summaryrefslogtreecommitdiff
path: root/service/test/support/test_helper.py
diff options
context:
space:
mode:
authorDuda Dornelles <dudassdorneles@gmail.com>2015-01-21 19:48:50 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-21 19:48:50 -0200
commit70e6d825d6b3e6804d42f931f30a18445650f9b2 (patch)
tree3708c88d252c30b08600895211d2f1938facfaca /service/test/support/test_helper.py
parent17617d102c0aa6a73cba51f1b6e425ec45384316 (diff)
#240 Adapted tests after change to twisted web
Diffstat (limited to 'service/test/support/test_helper.py')
-rw-r--r--service/test/support/test_helper.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/service/test/support/test_helper.py b/service/test/support/test_helper.py
index ff1de64a..f43776d1 100644
--- a/service/test/support/test_helper.py
+++ b/service/test/support/test_helper.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from datetime import datetime
+import io
from pixelated.adapter.model.mail import InputMail
@@ -79,3 +80,23 @@ class TestRequest:
def __init__(self, json):
self.json = json
+
+
+from twisted.web.test.test_web import DummyRequest
+
+
+class PixRequestMock(DummyRequest):
+ def __init__(self, path):
+ DummyRequest.__init__(self, path)
+ self.content = None
+ self.code = None
+
+
+def request_mock(path='', method='GET', body='', headers={}):
+ dummy = PixRequestMock(path.split('/'))
+ for name, value in headers.iteritems():
+ dummy.setHeader(name, value)
+ dummy.method = method
+ dummy.content = io.BytesIO(body)
+ return dummy
+