summaryrefslogtreecommitdiff
path: root/service/test/unit
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-09-21 18:10:17 -0300
committerGiovane <giovaneliberato@gmail.com>2015-09-21 18:10:17 -0300
commit8d20d0fa7ed226735daba4b0507cf0037860af71 (patch)
tree0c42b44c476dd3750e196f5cec94affdff8da6ce /service/test/unit
parentb492d6928dc757e56404a1a6f0d632658c38bc13 (diff)
#442 Creates feedback service that create tickets on leap web.
Diffstat (limited to 'service/test/unit')
-rw-r--r--service/test/unit/resources/test_feedback_resource.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/service/test/unit/resources/test_feedback_resource.py b/service/test/unit/resources/test_feedback_resource.py
new file mode 100644
index 00000000..63e6efc4
--- /dev/null
+++ b/service/test/unit/resources/test_feedback_resource.py
@@ -0,0 +1,27 @@
+import json
+from mockito import verify, mock, when
+from twisted.trial import unittest
+from twisted.web.test.requesthelper import DummyRequest
+from pixelated.resources.feedback_resource import FeedbackResource
+from test.unit.resources import DummySite
+
+
+class TestFeedbackResource(unittest.TestCase):
+ def setUp(self):
+ self.feedback_service = mock()
+ self.web = DummySite(FeedbackResource(self.feedback_service))
+
+ def test_sends_feedback_to_leap_web(self):
+ request = DummyRequest(['/feedback'])
+ request.method = 'POST'
+ content = mock()
+ when(content).read().thenReturn(json.dumps({'feedback': 'Pixelated is awesome!'}))
+ request.content = content
+
+ d = self.web.get(request)
+
+ def assert_posted_feedback_to_leap_web(_):
+ verify(self.feedback_service).open_ticket('Pixelated is awesome!')
+
+ d.addCallback(assert_posted_feedback_to_leap_web)
+ return d