コード例 #1
0
 def test_only_huge_street(self):
     v_address_cmd = generate_validate_address_cmd(street='a' * 81)
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'street': 'Has 81 characters and it must have 80 or less',
                              'access_data': 'Must save access data before making payments'})
コード例 #2
0
 def test_absent_street(self):
     v_address_cmd = generate_validate_address_cmd(street='')
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'street': 'Required field',
                              'access_data': 'Must save access data before making payments'})
コード例 #3
0
    def test_third_absent_quantity_invalid_reference(self):
        self.maxDiff = None
        v_address_cmd = generate_validate_address_cmd(street='', number='', postalcode='', town='a', state='SPP',
                                                      complement='a' * 41)
        invalid_description_item_cmd = ValidateItemCmd(description='', price='', quantity='', reference='a')
        cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd,

                                       valid_item_cmds[0],
                                       valid_item_cmds[1],
                                       invalid_description_item_cmd)  # not passing any items here as third parameter
        self.assertRaises(CommandExecutionException, cmd)
        item_errors = [{}, {},
            {'description': 'Required field', 'price': 'Required field', 'quantity': 'Required field',
             'reference': 'Invalid key'}]
        self.assertListEqual(item_errors, cmd.errors['items'])
        self.assert_errors(cmd, {'email': 'Invalid email',
                                 'name': 'Nome informado deve ser completo',
                                 'street': 'Required field',
                                 'number': 'Required field',
                                 'postalcode': 'Required field',
                                 'town': 'Has 1 characters and it must have 2 or more',
                                 'state': 'Has 3 characters and it must have exactly 2',
                                 'complement': 'Has 41 characters and it must have 40 or less',
                                 'items': item_errors,
                                 'access_data': 'Must save access data before making payments'})
コード例 #4
0
 def test_invalid_postalcode(self):
     v_address_cmd = generate_validate_address_cmd(street='', number='', postalcode='1234567')
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'street': 'Required field',
                              'number': 'Required field',
                              'postalcode': 'CEP must have exactly 8 characters',
                              'access_data': 'Must save access data before making payments'})
コード例 #5
0
 def test_tiny_town(self):
     v_address_cmd = generate_validate_address_cmd(street='', number='', postalcode='', town='a')
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'street': 'Required field',
                              'number': 'Required field',
                              'postalcode': 'Required field',
                              'town': 'Has 1 characters and it must have 2 or more',
                              'access_data': 'Must save access data before making payments'})
コード例 #6
0
 def __init__(self, redirect_url, client_name, client_email, payment_owner,
              validate_address_cmd, *validate_item_cmds):
     validate_data_cmd = ValidatePagseguroDataCmd(client_name, client_email,
                                                  validate_address_cmd,
                                                  *validate_item_cmds)
     save_data_cmd = SavePagseguroDataCmd()
     save_arcs_cmd = SavePaymentArcsCmd(payment_owner)
     self.__contact_pagseguro_cmd = ContactPagseguro(redirect_url)
     super(GeneratePayment,
           self).__init__(validate_data_cmd, save_data_cmd, save_arcs_cmd,
                          self.__contact_pagseguro_cmd,
                          UpdatePaymentAndSaveLog())
     self.checkout_code = None
コード例 #7
0
    def test_success(self):
        CreateOrUpdateAccessData('*****@*****.**', 'token_code')()
        v_address_cmd = generate_validate_address_cmd()

        cmd = ValidatePagseguroDataCmd('Renzo Nuccitelli', '*****@*****.**', v_address_cmd,
                                       ValidateItemCmd(description='Python Birds', price='18.99', quantity='3',
                                                       reference=ndb.Key(Reference, 1)), *valid_item_cmds)
        cmd()  # Should execute without exception

        # asserting data used for in sequential commands are exposed
        self.assertEqual(3, len(cmd.items), 'number of forms should be the same of ValidateItemCommands')
        self.assertIsInstance(cmd.items[0], PagSegItem)
        self.assertEqual(cmd.access_data, FindAccessDataCmd()())
        self.assertIsInstance(cmd.address_form, AddressForm)
        self.assertIsInstance(cmd.client_form, ClientForm)
コード例 #8
0
 def test_absent_item_complement(self):
     self.maxDiff = None
     v_address_cmd = generate_validate_address_cmd(street='', number='', postalcode='', town='a', state='SPP',
                                                   complement='a' * 41)
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd)  # not passing any items here as third parameter
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'street': 'Required field',
                              'number': 'Required field',
                              'postalcode': 'Required field',
                              'town': 'Has 1 characters and it must have 2 or more',
                              'state': 'Has 3 characters and it must have exactly 2',
                              'complement': 'Has 41 characters and it must have 40 or less',
                              'item_number': 'Should have one item at least',
                              'access_data': 'Must save access data before making payments'})
コード例 #9
0
 def test_first_invalid_item_complement(self):
     self.maxDiff = None
     v_address_cmd = generate_validate_address_cmd(street='', number='', postalcode='', town='a', state='SPP',
                                                   complement='a' * 41)
     invalid_description_item_cmd = ValidateItemCmd(description='', price=Decimal('18.99'), quantity=1)
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', v_address_cmd,
                                    invalid_description_item_cmd,
                                    valid_item_cmds[0])  # not passing any items here as third parameter
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'street': 'Required field',
                              'number': 'Required field',
                              'postalcode': 'Required field',
                              'town': 'Has 1 characters and it must have 2 or more',
                              'state': 'Has 3 characters and it must have exactly 2',
                              'complement': 'Has 41 characters and it must have 40 or less',
                              'items': [{'description': 'Required field'},
                                  {}],
                              'access_data': 'Must save access data before making payments'})
コード例 #10
0
 def test_only_first_client_name(self):
     cmd = ValidatePagseguroDataCmd('Renzo', 'a@foo', valid_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'email': 'Invalid email',
                              'name': 'Nome informado deve ser completo',
                              'access_data': 'Must save access data before making payments'})
コード例 #11
0
 def test_access_data_not_saved(self):
     cmd = ValidatePagseguroDataCmd('Renzo Nuccitelli', '*****@*****.**', valid_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'access_data': 'Must save access data before making payments'})
コード例 #12
0
 def assert_email_error(self, email, error_msg):
     cmd = ValidatePagseguroDataCmd('Jhon Doe', email, valid_address_cmd, *valid_item_cmds)
     self.assert_errors(cmd, {'email': error_msg,
                              'access_data': 'Must save access data before making payments'})