def test_update_shipping_method(self):
        adapter = IShoppingSite(self.portal)
        self.assertIsNone(adapter.shipping_method())

        adapter.update_shipping_method()
        self.assertIsNone(adapter.shipping_method())

        session = adapter.getSessionData(create=True)
        session.set('collective.cart.core', {'articles': {
            '1': {'gross': self.money('10.00'), 'quantity': 2, 'vat_rate': 24.0}
        }})
        adapter.update_shipping_method()
        self.assertIsNone(adapter.shipping_method())

        alsoProvides(self.portal, IShoppingSiteRoot)
        container = self.create_content('collective.cart.shipping.ShippingMethodContainer')
        shippingmethod1 = self.create_atcontent('ShippingMethod', container, id='shippingmethod1', vat=self.decimal('24.00'))
        uuid1 = IUUID(shippingmethod1)
        adapter.update_shipping_method()
        self.assertEqual(adapter.shipping_method(), {
            'gross': None,
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': None,
            'vat': None,
            'weight_dimension_rate': 250.0
        })

        articles = {'1': {'gross': self.money('10.00'), 'quantity': 2, 'weight': 100.0, 'depth': 10.0, 'height': 20.0, 'width': 30.0, 'vat_rate': 24.0}}
        adapter.update_cart('articles', articles)
        adapter.update_shipping_method()

        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('3.00'),
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('2.28'),
            'vat': self.money('0.72'),
            'weight_dimension_rate': 250.0
        })

        articles = {'1': {'gross': self.money('10.00'), 'quantity': 4, 'weight': 100.0, 'depth': 10.0, 'height': 20.0, 'width': 30.0, 'vat_rate': 24.0}}
        adapter.update_cart('articles', articles)
        adapter.update_shipping_method(uuid1)
        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('6.00'),
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('4.56'),
            'vat': self.money('1.44'),
            'weight_dimension_rate': 250.0
        })

        articles = {'1': {'gross': self.money('10.00'), 'quantity': 2, 'weight': 100.0, 'depth': 10.0, 'height': 20.0, 'width': 30.0, 'vat_rate': 24.0}}
        adapter.update_cart('articles', articles)
        adapter.update_shipping_method('UUID')
        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('3.00'),
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('2.28'),
            'vat': self.money('0.72'),
            'weight_dimension_rate': 250.0
        })

        articles = {'1': {'gross': self.money('10.00'), 'quantity': 4, 'weight': 100.0, 'depth': 10.0, 'height': 20.0, 'width': 30.0, 'vat_rate': 24.0}}
        adapter.update_cart('articles', articles)
        adapter.update_shipping_method(uuid1)
        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('6.00'),
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('4.56'),
            'vat': self.money('1.44'),
            'weight_dimension_rate': 250.0
        })

        shippingmethod2 = self.create_atcontent('ShippingMethod', container, id='shippingmethod2', vat=self.decimal('24.00'), weight_dimension_rate=1.0)
        uuid2 = IUUID(shippingmethod2)
        articles = {'1': {'gross': self.money('10.00'), 'quantity': 2, 'weight': 100.0, 'depth': 10.0, 'height': 20.0, 'width': 30.0, 'vat_rate': 24.0}}
        adapter.update_cart('articles', articles)
        adapter.update_shipping_method(uuid2)
        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('0.20'),
            'max_delivery_days': None,
            'uuid': uuid2,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('0.15'),
            'vat': self.money('0.05'),
            'weight_dimension_rate': 1.0
        })

        articles = {'1': {'gross': self.money('10.00'), 'quantity': 4, 'weight': 100.0, 'depth': 10.0, 'height': 20.0, 'width': 30.0, 'vat_rate': 24.0}}
        adapter.update_cart('articles', articles)
        adapter.update_shipping_method(uuid1)
        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('6.00'),
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('4.56'),
            'vat': self.money('1.44'),
            'weight_dimension_rate': 250.0
        })

        adapter.remove_from_cart('shipping_method')
        self.assertIsNone(adapter.shipping_method())
        adapter.update_shipping_method(uuid1)
        self.assertEqual(adapter.shipping_method(), {
            'gross': self.money('6.00'),
            'max_delivery_days': None,
            'uuid': uuid1,
            'title': '',
            'min_delivery_days': None,
            'vat_rate': self.decimal('24.00'),
            'net': self.money('4.56'),
            'vat': self.money('1.44'),
            'weight_dimension_rate': 250.0
        })