From 7901cb59a5924f8b21462d4f58332fced842c91a Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Mon, 4 Jan 2016 11:46:23 +0100 Subject: Decouple test_feedback_service from dev provider - Mock request instead --- service/test/integration/test_feedback_service.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'service/test/integration') diff --git a/service/test/integration/test_feedback_service.py b/service/test/integration/test_feedback_service.py index dd32374e..c50c1883 100644 --- a/service/test/integration/test_feedback_service.py +++ b/service/test/integration/test_feedback_service.py @@ -1,16 +1,23 @@ -import os import unittest +from httmock import urlmatch, HTTMock from mockito import when from twisted.internet import defer from test.support.integration import AppTestClient +@urlmatch(netloc=r'some.leap-provider.tld$') +def google_mock(url, request): + return 'Pixelated is awesome!' + + class TestFeedbackService(unittest.TestCase, AppTestClient): + @defer.inlineCallbacks def test_open_ticket(self): - yield self.start_client() - self.feedback_service.FEEDBACK_URL = "https://dev.pixelated-project.org/tickets" - when(self.leap_session).account_email().thenReturn("text@pixelated-project.org") - response = self.feedback_service.open_ticket("Pixelated is awesome!") + with HTTMock(google_mock): + yield self.start_client() + self.feedback_service.FEEDBACK_URL = "https://some.leap-provider.tld/tickets" + when(self.leap_session).account_email().thenReturn("text@pixelated-project.org") + response = self.feedback_service.open_ticket("Pixelated is awesome!") - self.assertEquals(response.status_code, 200) + self.assertEquals(response.status_code, 200) -- cgit v1.2.3