def test_get_first_valid_shipping_method(self):
        # Prepare request
        user = User.objects.get(username="admin")
        request = DummyRequest(user=user)

        # Create a weigth criterion and add it to the shipping method 1.
        c = WeightCriterion.objects.create(content=self.sm1, value=10.0, operator=LESS_THAN)

        # Create a weigth criterion and add it to the shipping method 2.
        c = WeightCriterion.objects.create(content=self.sm2, value=10.0, operator=GREATER_THAN)

        # For product 1 (weight: 6.0) the sm1 is the first valid (weight: 5.0 - 10.0)
        result = utils.get_first_valid_shipping_method(request, product=self.p1)
        self.assertEqual(result, self.sm1)

        # For product 1 (weight: 12.0) the sm1 is the first valid (weigth: > 10.0)
        result = utils.get_first_valid_shipping_method(request, product=self.p2)
        self.assertEqual(result, self.sm2)
Test utils.get_first_valid_shipping_method
dataset/ETHPy150Open diefenbach/django-lfs/lfs/shipping/tests.py/ShippingMethodTestCase.test_get_first_valid_shipping_method