Log in as Manager::

    >>> browser.login(TEST_USER_NAME, TEST_USER_PASSWORD)

Assign cart portlet to shop::

    >>> browser.open('/shop/++contextportlets++plone.leftcolumn/+/collective.cart.core.CartPortlet')

Log out::

    >>> browser.getLink('Log out').click()


Log in as member1::

    >>> browser.login(member1, member1)

Go to Ärticle1::

    >>> browser.open('/shop/article1')

Add Ärticle1 to cart::

    >>> browser.getControl(name="form.buttons.AddToCart").click()

Go to cart::

    >>> browser.getLink('Go to cart').click()

Check out::

    >>> browser.getControl(name="form.buttons.CheckOut").click()

Fill Billing Info and select Shipping Methöd 2::

    >>> browser.getControl(name="billing_first_name").value = 'Bılling First'
    >>> browser.getControl(name="billing_last_name").value = 'Bılling Last'
    >>> browser.getControl(name="billing_organization").value = 'Bılling Organization'
    >>> browser.getControl(name="billing_vat").value = 'Bılling VAT'
    >>> browser.getControl(name="billing_email").value = 'first.last@email.bil'
    >>> browser.getControl(name="billing_street").value = 'Bılling Street'
    >>> browser.getControl(name="billing_post").value = 'Bılling Post'
    >>> browser.getControl(name="billing_city").value = 'Bılling City'
    >>> browser.getControl(name="billing_phone").value = 'Bılling Phone'
    >>> browser.getControl(name="shipping-method").value = [shippingmethod2_uuid]
    >>> browser.getControl(name="form.buttons.CheckOut").click()

Confirm order::

    >>> browser.getControl(name="form.buttons.CheckOut").click()

Check the newest message sent::

    >>> len(mailhost.messages)
    2

    >>> msg = mailhost.messages[-2]
    >>> prink(msg)
    MIME-Version: 1.0
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Subject: =?utf-8?q?Order_Number=3A_1?=
    To: =?utf-8?q?B=C4=B1lling_First_B=C4=B1lling_Last?= <first.last@email.bil>
    From: =?utf-8?q?Sh=C3=B6p?= <info@shop.com>
    Date: ...
    <BLANKLINE>
    Thank you for the order.
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Number: 1
    <BLANKLINE>
    <BLANKLINE>
    Billing Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    B=C4=B1lling First B=C4=B1lling Last  B=C4=B1lling Organization  B=C4=B1lli=
    ng VAT
    B=C4=B1lling Street
    B=C4=B1lling Post B=C4=B1lling City
    B=C4=B1lling Phone
    first.last@email.bil
    <BLANKLINE>
    Shipping Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    B=C4=B1lling First B=C4=B1lling Last  B=C4=B1lling Organization  B=C4=B1lli=
    ng VAT
    B=C4=B1lling Street
    B=C4=B1lling Post B=C4=B1lling City
    B=C4=B1lling Phone
    first.last@email.bil
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Contents
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    <BLANKLINE>
    SKU: SK=C3=961
    =C3=84rticle1 x 1 =3D 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Shipping Method: ShippingMeth=C3=B6d2
    <BLANKLINE>
    Total: 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Link to the order: http://nohost/plone/shop/order-container/1
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>

    >>> msg = mailhost.messages[-1]
    >>> prink(msg)
    MIME-Version: 1.0
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Subject: =?utf-8?q?Order_Number=3A_1?=
    To: =?utf-8?q?Sh=C3=B6p?= <info@shop.com>
    From: =?utf-8?q?Sh=C3=B6p?= <info@shop.com>
    Date: ...
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Number: 1
    <BLANKLINE>
    <BLANKLINE>
    Billing Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    B=C4=B1lling First B=C4=B1lling Last  B=C4=B1lling Organization  B=C4=B1lli=
    ng VAT
    B=C4=B1lling Street
    B=C4=B1lling Post B=C4=B1lling City
    B=C4=B1lling Phone
    first.last@email.bil
    <BLANKLINE>
    Shipping Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    B=C4=B1lling First B=C4=B1lling Last  B=C4=B1lling Organization  B=C4=B1lli=
    ng VAT
    B=C4=B1lling Street
    B=C4=B1lling Post B=C4=B1lling City
    B=C4=B1lling Phone
    first.last@email.bil
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Contents
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    <BLANKLINE>
    SKU: SK=C3=961
    =C3=84rticle1 x 1 =3D 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Shipping Method: ShippingMeth=C3=B6d2
    <BLANKLINE>
    Total: 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Link to the order: http://nohost/plone/shop/order-container/1
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>

Thanks page::

    >>> browser.url
    'http://nohost/plone/shop/@@thanks'

Go to Ärticle1::

    >>> browser.open('/shop/article1')

Add Ärticle1 to cart::

    >>> browser.getControl(name="form.buttons.AddToCart").click()

Go to cart::

    >>> browser.getLink('Go to cart').click()

Check out and there should be billing info filled::

    >>> browser.getControl(name="form.buttons.CheckOut").click()

    >>> 'value="Bılling First"' in browser.contents
    True
    >>> 'value="Bılling Last"' in browser.contents
    True
    >>> 'value="Bılling Organization"' in browser.contents
    True
    >>> 'value="Bılling VAT"' in browser.contents
    True
    >>> 'value="first.last@email.bil"' in browser.contents
    True
    >>> 'value="Bılling Street"' in browser.contents
    True
    >>> 'value="Bılling Post"' in browser.contents
    True
    >>> 'value="Bılling City"' in browser.contents
    True
    >>> 'value="Bılling Phone"' in browser.contents
    True
    >>> print browser.bycss('.shipping-methods')
        --- 1 ---
    ...
    <input name="shipping-method" type="radio" required="required" checked value="...">
    ShippingMeth&#246;d2
    ...

With different shipping address::

    >>> browser.getControl(name="billing-same-as-shipping").value = ['different']
    >>> browser.getControl(name="form.buttons.CheckOut").click()

Input shipping info::

    >>> browser.getControl(name="shipping_first_name").value = 'Shıpping First'
    >>> browser.getControl(name="shipping_last_name").value = 'Shıpping Last'
    >>> browser.getControl(name="shipping_organization").value = 'Shıpping Organization'
    >>> browser.getControl(name="shipping_vat").value = 'Shıpping VAT'
    >>> browser.getControl(name="shipping_email").value = 'first.last@email.shi'
    >>> browser.getControl(name="shipping_street").value = 'Shıpping Street'
    >>> browser.getControl(name="shipping_post").value = 'Shıpping Post'
    >>> browser.getControl(name="shipping_city").value = 'Shıpping City'
    >>> browser.getControl(name="shipping_phone").value = 'Shıpping Phone'
    >>> browser.getControl(name="form.buttons.CheckOut").click()

Confirm order::

    >>> browser.getControl(name="form.buttons.CheckOut").click()

Thanks page::

    >>> browser.url
    'http://nohost/plone/shop/@@thanks'

    >>> browser.reload()
    >>> browser.url
    'http://nohost/plone/shop/@@cart'

Check the newest message sent::

    >>> len(mailhost.messages)
    4

    >>> msg = mailhost.messages[-2]
    >>> prink(msg)
    MIME-Version: 1.0
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Subject: =?utf-8?q?Order_Number=3A_2?=
    To: =?utf-8?q?B=C4=B1lling_First_B=C4=B1lling_Last?= <first.last@email.bil>
    From: =?utf-8?q?Sh=C3=B6p?= <info@shop.com>
    Date: ...
    <BLANKLINE>
    Thank you for the order.
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Number: 2
    <BLANKLINE>
    <BLANKLINE>
    Billing Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    B=C4=B1lling First B=C4=B1lling Last  B=C4=B1lling Organization  B=C4=B1lli=
    ng VAT
    B=C4=B1lling Street
    B=C4=B1lling Post B=C4=B1lling City
    B=C4=B1lling Phone
    first.last@email.bil
    <BLANKLINE>
    Shipping Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    Sh=C4=B1pping First Sh=C4=B1pping Last  Sh=C4=B1pping Organization  Sh=C4=
    =B1pping VAT
    Sh=C4=B1pping Street
    Sh=C4=B1pping Post Sh=C4=B1pping City
    Sh=C4=B1pping Phone
    first.last@email.shi
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Contents
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    <BLANKLINE>
    SKU: SK=C3=961
    =C3=84rticle1 x 1 =3D 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Shipping Method: ShippingMeth=C3=B6d2
    <BLANKLINE>
    Total: 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Link to the order: http://nohost/plone/shop/order-container/2
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>

    >>> msg = mailhost.messages[-1]
    >>> prink(msg)
    MIME-Version: 1.0
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: quoted-printable
    Subject: =?utf-8?q?Order_Number=3A_2?=
    To: =?utf-8?q?Sh=C3=B6p?= <info@shop.com>
    From: =?utf-8?q?Sh=C3=B6p?= <info@shop.com>
    Date: ...
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Number: 2
    <BLANKLINE>
    <BLANKLINE>
    Billing Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    B=C4=B1lling First B=C4=B1lling Last  B=C4=B1lling Organization  B=C4=B1lli=
    ng VAT
    B=C4=B1lling Street
    B=C4=B1lling Post B=C4=B1lling City
    B=C4=B1lling Phone
    first.last@email.bil
    <BLANKLINE>
    Shipping Address
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    Sh=C4=B1pping First Sh=C4=B1pping Last  Sh=C4=B1pping Organization  Sh=C4=
    =B1pping VAT
    Sh=C4=B1pping Street
    Sh=C4=B1pping Post Sh=C4=B1pping City
    Sh=C4=B1pping Phone
    first.last@email.shi
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
    Order Contents
    =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
    =3D=3D=3D
    <BLANKLINE>
    SKU: SK=C3=961
    =C3=84rticle1 x 1 =3D 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Shipping Method: ShippingMeth=C3=B6d2
    <BLANKLINE>
    Total: 12.40 =E2=82=AC
    <BLANKLINE>
    <BLANKLINE>
    Link to the order: http://nohost/plone/shop/order-container/2
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>

Log in as Manager::

    >>> browser.login(TEST_USER_NAME, TEST_USER_PASSWORD)

Check the stock of article1::

    >>> browser.open('/shop/article1/@@stock')
    >>> print browser.bycss('.documentFirstHeading')
    --- 1 ---
    <h1 class="documentFirstHeading">&#196;rticle1: 8 pcs</h1>

Go to Order Container::

    >>> browser.open('/shop/order-container')
    >>> print browser.bycss('#order-listing')
    --- 1 ---
    <section id="order-listing"><table class="listing"><thead><tr><th>No.</th>
    <th>Updated</th>
    <th>Owner</th>
    <th>State</th>
    <th>Change State</th>
    </tr></thead><tbody><tr><td>
    <a href="http://nohost/plone/shop/order-container/...">...</a>
    </td>
    <td>...</td>
    <td>member1</td>
    <td>Ordered</td>
    <td>
    <button name="form.buttons.ChangeState" type="submit" value="...:canceled">Canceled</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:paid">Paid</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:charged">Charged</button>
    </td>
    </tr><tr><td>
    <a href="http://nohost/plone/shop/order-container/...">...</a>
    </td>
    <td>...</td>
    <td>member1</td>
    <td>Ordered</td>
    <td>
    <button name="form.buttons.ChangeState" type="submit" value="...:canceled">Canceled</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:paid">Paid</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:charged">Charged</button>
    </td>
    </tr></tbody></table></section>

Cancel the order::

    >>> browser.getControl(name="form.buttons.ChangeState", index=0).click()

    >>> browser.open('/shop/article1/@@stock')
    >>> print browser.bycss('.documentFirstHeading')
    --- 1 ---
    <h1 class="documentFirstHeading">&#196;rticle1: 9 pcs</h1>

    >>> browser.open('/shop/order-container')
    >>> print browser.bycss('#order-listing')
    --- 1 ---
    <section id="order-listing"><table class="listing"><thead><tr><th>No.</th>
    ...
    <td>member1</td>
    <td>Canceled</td>
    <td>
    <button name="form.buttons.RemoveOrder" type="submit" value="...">Remove</button>
    </td>
    </tr><tr><td>
    ...
    </tr></tbody></table></section>

    >>> print browser.bycss('#order-listing')
    --- 1 ---
    <section id="order-listing"><table class="listing"><thead><tr><th>No.</th>
    ...
    <td>member1</td>
    <td>Ordered</td>
    <td>
    <button name="form.buttons.ChangeState" type="submit" value="...:canceled">Canceled</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:paid">Paid</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:charged">Charged</button>
    ...
    </tr></tbody></table></section>

Remove order::

    >>> browser.getControl(name="form.buttons.RemoveOrder").click()
    >>> print browser.bycss('#order-listing')
    --- 1 ---
    <section id="order-listing"><table class="listing"><thead><tr><th>No.</th>
    ...
    <td>member1</td>
    <td>Ordered</td>
    <td>
    <button name="form.buttons.ChangeState" type="submit" value="...:canceled">Canceled</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:paid">Paid</button>
    <button name="form.buttons.ChangeState" type="submit" value="...:charged">Charged</button>
    </td>
    </tr></tbody></table></section>

Change state::

    >>> browser.getControl(name="form.buttons.ChangeState", index=0).click()
    >>> browser.open('/shop/article1/@@stock')
    >>> print browser.bycss('.documentFirstHeading')
    --- 1 ---
    <h1 class="documentFirstHeading">&#196;rticle1: 10 pcs</h1>

Remove order::

    >>> browser.open('/shop/order-container')
    >>> browser.getControl(name="form.buttons.RemoveOrder").click()
    >>> print browser.bycss('#order-listing')
    --- 1 ---
    <section id="order-listing"><p id="no-orders">
    There are no orders.
    </p>
    </section>
