def test_get_shipping_gross_money(self):
        alsoProvides(self.portal, IShoppingSiteRoot)
        adapter = IShoppingSite(self.portal)
        self.assertIsNone(adapter.get_shipping_gross_money('UUID'))

        container = self.create_content('collective.cart.shipping.ShippingMethodContainer')
        shippingmethod1 = self.create_atcontent('ShippingMethod', container, id='shippingmethod1')
        uuid1 = IUUID(shippingmethod1)
        self.assertEqual(adapter.get_shipping_gross_money(uuid1), self.money('0.00'))
    def shipping_methods(self):
        """Returns list of dictionary of shipping methods

        :rtype: list
        """
        shopping_site = IShoppingSite(self.context)
        default_charset = getattr(getattr(getToolByName(
            self.context, 'portal_properties'), 'site_properties'), 'default_charset', 'utf-8')
        res = []
        for brain in shopping_site.shipping_methods():
            uuid = brain.UID
            orig_uuid = shopping_site.shipping_method()['uuid']

            if uuid == orig_uuid:
                shipping_gross_money = shopping_site.shipping_gross_money()
            else:
                shipping_gross_money = shopping_site.get_shipping_gross_money(uuid)

            if shipping_gross_money.amount == 0.0:
                title = brain.Title
            else:
                title = '{}  {}'.format(brain.Title, shopping_site.format_money(shipping_gross_money).encode(default_charset))

            res.append({
                'description': brain.Description,
                'checked': uuid == orig_uuid,
                'title': title,
                'uuid': uuid,
            })

        return res
    def test_shipping_gross_money(self):
        adapter = IShoppingSite(self.portal)
        adapter.shipping_method = mock.Mock(return_value=None)
        self.assertIsNone(adapter.shipping_gross_money())

        adapter.get_shipping_gross_money = mock.Mock()
        adapter.shipping_method = mock.Mock(return_value={'uuid': 'UUID'})
        adapter.shipping_gross_money()
        adapter.get_shipping_gross_money.assert_called_with('UUID')