Exemplo n.º 1
0
class TestRequestToken(unittest.TestCase):
    """
    Unit test for PlurkOAuth.get_request_token
    """
    def setUp(self):
        """ Create mock oauth object """
        self.mox = mox.Mox()
        self.oauth = PlurkOAuth("CONSUMER_KEY", "CONSUMER_SECRET")
        self.oauth_response = \
            'oauth_token_secret=O7WqqqWHA61f4ZE5izQdTQmK&oauth_token=ReqXBFOswcyR&oauth_callback_confirmed=true'  # NOQA
        self.golden_token = dict(parse_qsl(self.oauth_response))
        self.mox.StubOutWithMock(PlurkOAuth, 'request')

    def tearDown(self):
        self.mox.UnsetStubs()

    def _200_request(self):
        return 200, self.oauth_response, ""

    def test_get_request_token(self):
        self.oauth.request(mox.IgnoreArg()).AndReturn(self._200_request())
        self.mox.ReplayAll()
        self.oauth.get_request_token()
        self.assertEqual(self.golden_token, self.oauth.oauth_token)
        self.mox.VerifyAll()
Exemplo n.º 2
0
class TestRequestToken(unittest.TestCase):
    """
    Unit test for PlurkOAuth.get_request_token
    """
    def setUp(self):
        """ Create mock oauth object """
        self.mox = mox.Mox()
        self.oauth = PlurkOAuth("CONSUMER_KEY", "CONSUMER_SECRET")
        self.oauth_response = \
            'oauth_token_secret=O7WqqqWHA61f4ZE5izQdTQmK&oauth_token=ReqXBFOswcyR&oauth_callback_confirmed=true'  # NOQA
        self.golden_token = dict(parse_qsl(self.oauth_response))
        self.mox.StubOutWithMock(PlurkOAuth, 'request')

    def tearDown(self):
        self.mox.UnsetStubs()

    def _200_request(self):
        return 200, self.oauth_response, ""

    def test_get_request_token(self):
        self.oauth.request(mox.IgnoreArg()).AndReturn(self._200_request())
        self.mox.ReplayAll()
        self.oauth.get_request_token()
        self.assertEqual(self.golden_token, self.oauth.oauth_token)
        self.mox.VerifyAll()
Exemplo n.º 3
0
 def setUp(self):
     """ Create mock oauth object """
     self.mox = mox.Mox()
     self.oauth = PlurkOAuth("CONSUMER_KEY", "CONSUMER_SECRET")
     self.oauth_response = \
         'oauth_token_secret=O7WqqqWHA61f4ZE5izQdTQmK&oauth_token=ReqXBFOswcyR&oauth_callback_confirmed=true'  # NOQA
     self.golden_token = dict(parse_qsl(self.oauth_response))
     self.mox.StubOutWithMock(PlurkOAuth, 'request')
Exemplo n.º 4
0
 def setUp(self):
     """ Create mock oauth object """
     self.mox = mox.Mox()
     self.oauth = PlurkOAuth("CONSUMER_KEY", "CONSUMER_SECRET")
     self.oauth_response = \
         'oauth_token_secret=O7WqqqWHA61f4ZE5izQdTQmK&oauth_token=ReqXBFOswcyR&oauth_callback_confirmed=true'  # NOQA
     self.golden_token = dict(parse_qsl(self.oauth_response))
     self.mox.StubOutWithMock(PlurkOAuth, 'request')