def test_shipping_address_is_prefilled(self, browser):
     checkout.visit_checkout_with_one_item_in_cart()
     checkout.fill_contact_info()
     browser.fill({'First Name': 'John', 'Last Name': 'Doe'})
     checkout.next()
     checkout.assert_step(checkout.SHIPPING_ADDRESS)
     self.assertEquals('John', browser.find('First Name').value)
     self.assertEquals('Doe', browser.find('Last Name').value)
    def test_valid_email_address_required(self, browser):
        checkout.visit_checkout_with_one_item_in_cart()
        browser.fill({'Email': 'invalid.email.ch'})
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)

        form = browser.css('form.kssattr-formname-checkout-wizard').first
        self.assertEquals(['This email address is invalid.'],
                          z3cform.erroneous_fields(form)[u'Email'])
 def test_shipping_address_is_prefilled(self, browser):
     checkout.visit_checkout_with_one_item_in_cart()
     checkout.fill_contact_info()
     browser.fill({'First Name': 'John',
                   'Last Name': 'Doe'})
     checkout.next()
     checkout.assert_step(checkout.SHIPPING_ADDRESS)
     self.assertEquals('John', browser.find('First Name').value)
     self.assertEquals('Doe', browser.find('Last Name').value)
 def checkout_and_get_mail(self, *items):
     mailing = Mailing(self.portal)
     for item in items:
         checkout.visit_checkout_with_one_item_in_cart(item)
     checkout.goto(checkout.ORDER_REVIEW).finish()
     self.assertEquals(1, len(mailing.get_messages()),
                       'Notifying shop owner is disabled by default, therefore'
                       ' only one mail (to the customer) should be sent.')
     return email.message_from_string(mailing.pop())
    def test_valid_email_address_required(self, browser):
        checkout.visit_checkout_with_one_item_in_cart()
        browser.fill({'Email': 'invalid.email.ch'})
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)

        form = browser.css('form.kssattr-formname-checkout-wizard').first
        self.assertEquals(
            ['This email address is invalid.'],
            z3cform.erroneous_fields(form)[u'Email'])
Exemple #6
0
 def checkout_and_get_mail(self, *items):
     mailing = Mailing(self.portal)
     for item in items:
         checkout.visit_checkout_with_one_item_in_cart(item)
     checkout.goto(checkout.ORDER_REVIEW).finish()
     self.assertEquals(
         1, len(mailing.get_messages()),
         'Notifying shop owner is disabled by default, therefore'
         ' only one mail (to the customer) should be sent.')
     return email.message_from_string(mailing.pop())
    def checkout_and_get_mail(self, *items):
        mailing = Mailing(self.portal)
        for item in items:
            checkout.visit_checkout_with_one_item_in_cart(item)
        checkout.goto(checkout.ORDER_REVIEW).finish()

        mails_by_recipient = mailing.get_messages_by_recipient()
        owner = 'Shop Owner <*****@*****.**>'
        self.assertIn(owner, mails_by_recipient,
                      'Expected a mail to the shop owner to be sent')
        return email.message_from_string(mails_by_recipient[owner][0])
 def test_order_review_shows_cart_items(self, browser):
     item = create(Builder('shop item')
                   .titled('Socks')
                   .having(description='A good pair of socks.',
                           price='10'))
     checkout.visit_checkout_with_one_item_in_cart(item=item)
     checkout.goto(checkout.ORDER_REVIEW)
     self.assertEquals([{'Product': 'Socks',
                         'Description': 'A good pair of socks.',
                         'Quantity': '1',
                         'Price': '10.00',
                         'Total': '10.00'}],
                       browser.css('table.cartListing').first.dicts(foot=False))
    def test_contact_information_defaults_for_user_without_fullname(self,
                                                                    browser):
        browser.login()
        checkout.visit_checkout_with_one_item_in_cart()
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)

        self.assertEquals(
            '',
            browser.css(
                '[name="contact_information.widgets.lastname"]').first.value)
        self.assertEquals(
            '',
            browser.css(
                '[name="contact_information.widgets.firstname"]').first.value)
 def test_order_review_shows_cart_items(self, browser):
     item = create(
         Builder('shop item').titled('Socks').having(
             description='A good pair of socks.', price='10'))
     checkout.visit_checkout_with_one_item_in_cart(item=item)
     checkout.goto(checkout.ORDER_REVIEW)
     self.assertEquals(
         [{
             'Product': 'Socks',
             'Description': 'A good pair of socks.',
             'Quantity': '1',
             'Price': '10.00',
             'Total': '10.00'
         }],
         browser.css('table.cartListing').first.dicts(foot=False))
    def test_contact_information_defaults_for_user_without_fullname(
            self, browser):
        browser.login()
        checkout.visit_checkout_with_one_item_in_cart()
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)

        self.assertEquals(
            '',
            browser.css(
                '[name="contact_information.widgets.lastname"]').first.value)
        self.assertEquals(
            '',
            browser.css(
                '[name="contact_information.widgets.firstname"]').first.value)
    def test_contact_information_defaults_for_logged_in_user(self, browser):
        hugo = create(Builder('user').named('H\xc3\xbcgo', 'B\xc3\xb6ss'))
        browser.login(hugo)

        checkout.visit_checkout_with_one_item_in_cart()
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)

        self.assertEquals(
            hugo.getProperty('fullname').split(' ')[1].decode('utf-8'),
            browser.css(
                '[name="contact_information.widgets.lastname"]').first.value)
        self.assertEquals(
            hugo.getProperty('fullname').split(' ')[0].decode('utf-8'),
            browser.css(
                '[name="contact_information.widgets.firstname"]').first.value)
    def test_contact_information_defaults_for_logged_in_user(self, browser):
        hugo = create(Builder('user').named('H\xc3\xbcgo', 'B\xc3\xb6ss'))
        browser.login(hugo)

        checkout.visit_checkout_with_one_item_in_cart()
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)

        self.assertEquals(
            hugo.getProperty('fullname').split(' ')[1].decode('utf-8'),
            browser.css(
                '[name="contact_information.widgets.lastname"]').first.value)
        self.assertEquals(
            hugo.getProperty('fullname').split(' ')[0].decode('utf-8'),
            browser.css(
                '[name="contact_information.widgets.firstname"]').first.value)
    def test_contact_information_fields_required(self, browser):
        checkout.visit_checkout_with_one_item_in_cart()
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)
        form = browser.css('form.kssattr-formname-checkout-wizard').first

        self.assertEquals(
            {u'Title': ['Required input is missing.'],
             u'First Name': ['Required input is missing.'],
             u'Last Name': ['Required input is missing.'],
             u'Email': ['Required input is missing.'],
             u'Street/No.': ['Required input is missing.'],
             u'Phone number': ['Required input is missing.'],
             u'Zip Code': ['Required input is missing.'],
             u'City': ['Required input is missing.'],
             u'Country': ['Required input is missing.']},
            z3cform.erroneous_fields(form))
    def test_contact_information_fields_required(self, browser):
        checkout.visit_checkout_with_one_item_in_cart()
        checkout.next()
        checkout.assert_step(checkout.CONTACT_INFORMATION)
        form = browser.css('form.kssattr-formname-checkout-wizard').first

        self.assertEquals(
            {
                u'Title': ['Required input is missing.'],
                u'First Name': ['Required input is missing.'],
                u'Last Name': ['Required input is missing.'],
                u'Email': ['Required input is missing.'],
                u'Street/No.': ['Required input is missing.'],
                u'Phone number': ['Required input is missing.'],
                u'Zip Code': ['Required input is missing.'],
                u'City': ['Required input is missing.'],
                u'Country': ['Required input is missing.']
            }, z3cform.erroneous_fields(form))
 def test_submitting_contact_information_leads_to_shipping_address(
         self, browser):
     checkout.visit_checkout_with_one_item_in_cart()
     checkout.submit_valid_contact_info()
     checkout.assert_step(checkout.SHIPPING_ADDRESS)
 def test_submitting_contact_information_leads_to_shipping_address(self, browser):
     checkout.visit_checkout_with_one_item_in_cart()
     checkout.submit_valid_contact_info()
     checkout.assert_step(checkout.SHIPPING_ADDRESS)