Beispiel #1
0
    def setUp(self):
        CanvasTestCase.setUp(self)
        # Grab a limited availability sticker
        self.sticker = stickers.Sticker(1234, "test", cost=10, maximum=100)

        # Call stickers.add_sticker so that we can use the sticker by id in api calls.
        stickers.add_sticker(self.sticker)
Beispiel #2
0
    def test_cant_purchase_limited_availability_multiple_times(self):
        # Grab a limited availability sticker
        sticker = self.sticker
        previous_inventory = sticker.remaining

        # Call stickers.add_sticker so that we can use the sticker by id in api calls.
        stickers.add_sticker(sticker)

        user = tests_helpers.create_rich_user()
        previous_wealth = user.kv.stickers.currency.get()

        # Give the user this sticker.
        # Give them zero for now.
        user.kv.stickers.add_limited_sticker(sticker)

        # Try to purchase. Should allow them
        result = self.api_post('/api/store/buy', {
            'item_type': 'sticker',
            'item_id': sticker.type_id
        },
                               user=user)
        # Should not be able to buy it a second time.
        result = self.api_post('/api/store/buy', {
            'item_type': 'sticker',
            'item_id': sticker.type_id
        },
                               user=user)
        assert result.get("success") == False

        assert sticker.remaining == previous_inventory - 1
Beispiel #3
0
    def setUp(self):
        CanvasTestCase.setUp(self)
        # Grab a limited availability sticker
        self.sticker = stickers.Sticker(1234, "test", cost=10, maximum=100)

        # Call stickers.add_sticker so that we can use the sticker by id in api calls.
        stickers.add_sticker(self.sticker)
Beispiel #4
0
 def setUp(self):
     CanvasTestCase.setUp(self)
     self.sticker = stickers.Sticker(1234,
                                     "foobar",
                                     limited=True,
                                     maximum=10,
                                     cost=10)
     stickers.add_sticker(self.sticker)
Beispiel #5
0
    def test_cant_purchase_limited_availability_multiple_times(self):
        # Grab a limited availability sticker
        sticker = self.sticker
        previous_inventory = sticker.remaining

        # Call stickers.add_sticker so that we can use the sticker by id in api calls.
        stickers.add_sticker(sticker)

        user = tests_helpers.create_rich_user()
        previous_wealth = user.kv.stickers.currency.get()

        # Give the user this sticker.
        # Give them zero for now.
        user.kv.stickers.add_limited_sticker(sticker)

        # Try to purchase. Should allow them
        result = self.api_post('/api/store/buy', {'item_type': 'sticker', 'item_id': sticker.type_id}, user=user)
        # Should not be able to buy it a second time.
        result = self.api_post('/api/store/buy', {'item_type': 'sticker', 'item_id': sticker.type_id}, user=user)
        assert result.get("success") == False

        assert sticker.remaining == previous_inventory - 1
 def setUp(self):
     CanvasTestCase.setUp(self)
     self.sticker = stickers.Sticker(11111, "test", cost=10, maximum=100)
     stickers.add_sticker(self.sticker)
 def setUp(self):
     CanvasTestCase.setUp(self)
     self.sticker = stickers.Sticker(11111, "test", cost=10, maximum=100)
     stickers.add_sticker(self.sticker)
Beispiel #8
0
 def setUp(self):
     CanvasTestCase.setUp(self)
     self.sticker = stickers.Sticker(1234, "foobar", limited=True, maximum=10, cost=10)
     stickers.add_sticker(self.sticker)