Exemplo n.º 1
0
class TestFlexiblePaymentsService(unittest.TestCase):
    def setUp(self):
        self.api_username = getattr(local_settings, 'AWS_ACCESS_KEY_ID', None)
        self.api_password = getattr(local_settings, 'AWS_SECRET_ACCESS_KEY', None)
        self.api_token_id = getattr(local_settings, 'AWS_FPS_TEST_TOKEN_ID', None)
        self.api = FlexiblePaymentsService(self.api_username, self.api_password, debug=True)

    def test_get_authorization_url(self):
        data = {}
        data['returnURL'] = 'https://metro-dev.apphosted.com/billing/notify'
        url = self.api.get_authorization_url('MultiUse', '1.0', 'Minimum', '12345', \
            '1000', 'Newservice', data)
        cj = cookielib.CookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        r = opener.open(url)
        cont = r.read()
        self.assertTrue(cont.find('Sign in with your Amazon account') > -1)
        self.assertTrue(cont.find('What is your e-mail address?') > -1)

    def test_get_transaction_status(self):
        resp = self.api.pay(self.api_token_id, '10.0', 'USD')
        self.assertTrue(resp.has_key('TransactionId'))
        t_id = resp['TransactionId']
        resp = self.api.get_transaction_status(t_id)
        self.assertTrue(resp.has_key('TransactionStatus'))
        self.assertTrue(resp.has_key('StatusCode'))
        self.assertTrue(resp.has_key('StatusMessage'))

    def test_pay(self):
        resp = self.api.pay(self.api_token_id, '25.0', 'USD')
        # parse 
        self.assertTrue(resp.has_key('TransactionId'))
        self.assertTrue(resp.has_key('RequestId'))
        self.assertTrue(resp.has_key('TransactionStatus'))

    def test_sign(self):
        data = {}
        data['CallerReference'] = str(uuid.uuid4())
        signed_data = self.api._sign(self.api._get_endpoint_host(self.api.get_api_endpoint()), '/', data)
        self.assertNotEqual(signed_data, None)
Exemplo n.º 2
0
 def setUp(self):
     self.api_username = getattr(local_settings, 'AWS_ACCESS_KEY_ID', None)
     self.api_password = getattr(local_settings, 'AWS_SECRET_ACCESS_KEY', None)
     self.api_token_id = getattr(local_settings, 'AWS_FPS_TEST_TOKEN_ID', None)
     self.api = FlexiblePaymentsService(self.api_username, self.api_password, debug=True)