def setUp(self): self.contact_info = ContactInfo(first_name='John', last_name='Doe', email='*****@*****.**', zip_='SW5', country='gb', phone='07777777777') self.credit_card = PlainCreditCard( card_type=helper.DUMMY_CARD_VISA['card_type'], expiration_month=helper.DUMMY_CARD_VISA['expiration_month'], expiration_year=helper.DUMMY_CARD_VISA['expiration_year'], card_number=helper.DUMMY_CARD_VISA['card_number'], security_code=helper.DUMMY_CARD_VISA['security_code']) self.second_credit_card = PlainCreditCard( card_type=helper.DUMMY_CARD_MASTERCARD['card_type'], expiration_month=helper.DUMMY_CARD_MASTERCARD['expiration_month'], expiration_year=helper.DUMMY_CARD_MASTERCARD['expiration_year'], card_number=helper.DUMMY_CARD_MASTERCARD['card_number'], security_code=helper.DUMMY_CARD_MASTERCARD['security_code']) self.third_credit_card = PlainCreditCard( card_type=helper.DUMMY_CARD_AMEX['card_type'], expiration_month=helper.DUMMY_CARD_AMEX['expiration_month'], expiration_year=helper.DUMMY_CARD_AMEX['expiration_year'], card_number=helper.DUMMY_CARD_AMEX['card_number'], security_code=helper.DUMMY_CARD_AMEX['security_code'])
def test_create_with_invalid_parameters(self): error_msg = ( 'Seller 397608 encountered a problem creating a new shopper due ' 'to incorrect input.') responses.add( responses.POST, '%s/services/2/shoppers' % client.default().endpoint_url, status=400, content_type='application/xml', body='''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <messages xmlns="http://ws.plimus.com"> <message> <description>%s</description> </message> <message> <code>10001</code> <description>'Email Address' is not a valid email address.</description> <invalid-property> <name>shopperInfo.shopperContactInfo.email</name> <message-value/> </invalid-property> </message> <message> <code>10001</code> <description>Field 'Email Address' is required.</description> <invalid-property> <name>shopperInfo.shopperContactInfo.email</name> <message-value/> </invalid-property> </message> <message> <code>10001</code> <description>Field 'Email Address' is required.</description> <invalid-property> <name>shopperInfo.invoiceContactsInfo.invoiceContactInfo.email</name> <message-value/> </invalid-property> </message> <message> <code>10001</code> <description>'Email Address' is not a valid email address.</description> <invalid-property> <name>shopperInfo.invoiceContactsInfo.invoiceContactInfo.email</name> <message-value/> </invalid-property> </message> </messages>''' % error_msg) shopper = ShopperResource() with self.assertRaises(exceptions.APIError) as cm: shopper.create(contact_info=ContactInfo(email=''), credit_card=self.credit_card) self.assertEqual(cm.exception.status_code, 400) self.assertEqual(cm.exception.description, 'None') self.assertGreater(len(cm.exception.messages), 1) self.assertEqual(cm.exception.messages[0]['description'], error_msg)
def test_create_with_invalid_parameters_encrypted(self): error_msg = 'Invalid encrypted input' responses.add( responses.POST, '%s/services/2/shoppers' % client.default().endpoint_url, status=400, content_type='application/xml', body='''<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <messages xmlns="http://ws.plimus.com"> <message> <code>19002</code> <description>%s</description> </message> </messages>''' % error_msg) shopper = ShopperResource() with self.assertRaises(exceptions.APIError) as cm: shopper.create(contact_info=ContactInfo(email=''), credit_card=self.encrypted_credit_card) self.assertEqual(cm.exception.status_code, 400) self.assertEqual(cm.exception.description, error_msg)
def setUp(self): self.contact_info = ContactInfo(first_name='John', last_name='Doe', email='*****@*****.**', zip_='SW5', country='gb', phone='07777777777') self.credit_card = PlainCreditCard( card_type=helper.DUMMY_CARD_VISA['card_type'], expiration_month=helper.DUMMY_CARD_VISA['expiration_month'], expiration_year=helper.DUMMY_CARD_VISA['expiration_year'], card_number=helper.DUMMY_CARD_VISA['card_number'], security_code=helper.DUMMY_CARD_VISA['security_code']) self.encrypted_credit_card = EncryptedCreditCard( card_type=helper.DUMMY_CARD_VISA['card_type'], expiration_month=helper.DUMMY_CARD_VISA['expiration_month'], expiration_year=helper.DUMMY_CARD_VISA['expiration_year'], encrypted_card_number='encrypted_%s' % helper.DUMMY_CARD_VISA['card_number'], encrypted_security_code=helper. DUMMY_CARD_VISA['encrypted_security_code']) self.credit_card_selection = CreditCardSelection( card_type=helper.DUMMY_CARD_VISA['card_type'], card_last_four_digits=helper.DUMMY_CARD_VISA['card_number'][-4:]) shopper = ShopperResource() self.shopper_id_with_one_credit_card = shopper.create( contact_info=self.contact_info, credit_card=self.credit_card) self.shopper_id_with_one_encrypted_credit_card = shopper.create( contact_info=self.contact_info, credit_card=self.encrypted_credit_card) self.shopper_id_without_credit_card = shopper.create( contact_info=self.contact_info) self.shopper_id_with_two_credit_cards = shopper.create( contact_info=self.contact_info, credit_card=self.credit_card) self.assertTrue( shopper.update( shopper_id=self.shopper_id_with_two_credit_cards, contact_info=self.contact_info, credit_card=PlainCreditCard( card_type=helper.DUMMY_CARD_MASTERCARD['card_type'], expiration_month=helper. DUMMY_CARD_MASTERCARD['expiration_month'], expiration_year=helper. DUMMY_CARD_MASTERCARD['expiration_year'], card_number=helper.DUMMY_CARD_MASTERCARD['card_number'], security_code=helper.DUMMY_CARD_MASTERCARD['security_code'] ))) self.shopper_id_with_two_encrypted_credit_cards = shopper.create( contact_info=self.contact_info, credit_card=self.encrypted_credit_card) self.assertTrue( shopper.update( shopper_id=self.shopper_id_with_two_encrypted_credit_cards, contact_info=self.contact_info, credit_card=EncryptedCreditCard( card_type=helper.DUMMY_CARD_MASTERCARD['card_type'], expiration_month=helper. DUMMY_CARD_MASTERCARD['expiration_month'], expiration_year=helper. DUMMY_CARD_MASTERCARD['expiration_year'], encrypted_card_number='encrypted_%s' % helper.DUMMY_CARD_MASTERCARD['card_number'], encrypted_security_code=helper. DUMMY_CARD_MASTERCARD['encrypted_security_code'])))