GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

test_reservable_has_only_passed_period_price_modifiers()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 4
rs 10
1
import datetime
2
from decimal import Decimal
3
4
from django.test import RequestFactory
5
from shoop.core.models import ShopProduct
6
7
from kakaravaara.tests import KakaravaaraTestsBase
8
from reservable_pricing.factories import PeriodPriceModifierFactory
9
from reservations.factories import ReservableProductFactory
10
11
12
class ReservablePricePerPersonTestCase(KakaravaaraTestsBase):
13
    def setUp(self):
14
        super(ReservablePricePerPersonTestCase, self).setUp()
15
        self.request = RequestFactory().get("/")
16
        self.request.GET = {"persons": 3}
17
        self.request.shop = self.shop
18
        self.reservable = ReservableProductFactory(
19
            pricing_per_person_included=0, pricing_per_person_price=Decimal("10.00"),
20
        )
21
22
    def test_reservable_with_pricing_per_person_disabled_person_count_doesnt_change_price(self):
23
        self.reservable.pricing_per_person = False
24
        self.reservable.save()
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named save.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
25
        price = self.reservable.product.get_price(self.request, quantity=1).quantize(Decimal("1.00"))
26
        shop_product = ShopProduct.objects.get(product_id=self.reservable.product_id, shop=self.shop)
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named product_id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
27
        self.assertEqual(price, shop_product.default_price)
28
29 View Code Duplication
    def test_reservable_with_pricing_per_person_active_person_count_changes_price(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
30
        self.reservable.pricing_per_person = True
31
        self.reservable.save()
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named save.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
32
        price = self.reservable.product.get_price(self.request, quantity=1).quantize(Decimal("1.00"))
33
        shop_product = ShopProduct.objects.get(product_id=self.reservable.product_id, shop=self.shop)
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named product_id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
34
        self.assertAlmostEqual(price.value, shop_product.default_price_value + 3 * Decimal("10.00"), 6)
0 ignored issues
show
Bug introduced by
The Instance of ReservablePricePerPersonTestCase does not seem to have a member named assertAlmostEqual.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
35
36 View Code Duplication
    def test_reservable_with_pricing_per_person_active_person_count_changes_price_more_nights(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
37
        self.reservable.pricing_per_person = True
38
        self.reservable.save()
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named save.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
39
        price = self.reservable.product.get_price(self.request, quantity=3).quantize(Decimal("1.00"))
40
        shop_product = ShopProduct.objects.get(product_id=self.reservable.product_id, shop=self.shop)
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named product_id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
41
        self.assertAlmostEqual(price.value, shop_product.default_price_value * 3 + 3 * Decimal("10.00") * 3, 6)
0 ignored issues
show
Bug introduced by
The Instance of ReservablePricePerPersonTestCase does not seem to have a member named assertAlmostEqual.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
42
43 View Code Duplication
    def test_reservable_with_pricing_per_person_included_count_zero(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
44
        self.reservable.pricing_per_person = True
45
        self.reservable.save()
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named save.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
46
        price = self.reservable.product.get_price(self.request, quantity=1).quantize(Decimal("1.00"))
47
        shop_product = ShopProduct.objects.get(product_id=self.reservable.product_id, shop=self.shop)
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named product_id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
48
        self.assertAlmostEqual(price.value, shop_product.default_price_value + 3 * Decimal("10.00"), 6)
0 ignored issues
show
Bug introduced by
The Instance of ReservablePricePerPersonTestCase does not seem to have a member named assertAlmostEqual.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
49
50 View Code Duplication
    def test_reservable_with_pricing_per_person_included_count_above_zero(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
51
        self.reservable.pricing_per_person = True
52
        self.reservable.pricing_per_person_included = 2
53
        self.reservable.save()
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named save.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
54
        price = self.reservable.product.get_price(self.request, quantity=1).quantize(Decimal("1.00"))
55
        shop_product = ShopProduct.objects.get(product_id=self.reservable.product_id, shop=self.shop)
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named product_id.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
56
        self.assertAlmostEqual(price.value, shop_product.default_price_value + Decimal("10.00"), 6)
0 ignored issues
show
Bug introduced by
The Instance of ReservablePricePerPersonTestCase does not seem to have a member named assertAlmostEqual.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
57
58
59
class ReservableHasPriceModifiersTestCase(KakaravaaraTestsBase):
60
    def setUp(self):
61
        super(ReservableHasPriceModifiersTestCase, self).setUp()
62
        self.reservable = ReservableProductFactory()
63
        self.tomorrow = datetime.date.today() + datetime.timedelta(days=1)
64
        self.yesterday = datetime.date.today() - datetime.timedelta(days=1)
65
66
    def test_reservable_has_no_modifiers(self):
67
        self.assertFalse(self.reservable.has_price_modifiers)
0 ignored issues
show
Bug introduced by
The Instance of ReservableHasPriceModifiersTestCase does not seem to have a member named assertFalse.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named has_price_modifiers.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
68
69
    def test_reservable_has_per_person_modifier(self):
70
        self.reservable.pricing_per_person = True
71
        self.reservable.save()
0 ignored issues
show
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named save.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
72
        self.assertTrue(self.reservable.has_price_modifiers)
0 ignored issues
show
Bug introduced by
The Instance of ReservableHasPriceModifiersTestCase does not seem to have a member named assertTrue.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named has_price_modifiers.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
73
74
    def test_reservable_has_period_price_modifiers(self):
75
        PeriodPriceModifierFactory(
76
            product=self.reservable.product, start_date=self.tomorrow, end_date=self.tomorrow)
77
        self.assertTrue(self.reservable.has_price_modifiers)
0 ignored issues
show
Bug introduced by
The Instance of ReservableHasPriceModifiersTestCase does not seem to have a member named assertTrue.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named has_price_modifiers.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
78
79
    def test_reservable_has_only_passed_period_price_modifiers(self):
80
        PeriodPriceModifierFactory(
81
            product=self.reservable.product, start_date=self.yesterday, end_date=self.yesterday)
82
        self.assertFalse(self.reservable.has_price_modifiers)
0 ignored issues
show
Bug introduced by
The Instance of ReservableHasPriceModifiersTestCase does not seem to have a member named assertFalse.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
Bug introduced by
The Instance of ReservableProductFactory does not seem to have a member named has_price_modifiers.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
83