File: test_discounts.py

package info (click to toggle)
python-braintree 3.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,376 kB
  • ctags: 1,998
  • sloc: python: 13,634; makefile: 73; sh: 8
file content (35 lines) | stat: -rw-r--r-- 1,215 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from tests.test_helper import *

class TestDiscounts(unittest.TestCase):

    def test_all_returns_all_discounts(self):
        new_id = str(random.randint(1, 1000000))
        attributes = {
            "amount": "100.00",
            "description": "some description",
            "id": new_id,
            "kind": "discount",
            "name": "python_discount",
            "never_expires": False,
            "number_of_billing_cycles": 1
        }

        Configuration.instantiate().http().post("/modifications/create_modification_for_tests", {"modification": attributes})

        discounts = Discount.all()

        for discount in discounts:
            if discount.id == new_id:
                break
        else:
            discount = None

        self.assertNotEquals(None, discount)

        self.assertEquals(discount.amount, Decimal("100.00"))
        self.assertEquals(discount.description, "some description")
        self.assertEquals(discount.id, new_id)
        self.assertEquals(discount.kind, "discount")
        self.assertEquals(discount.name, "python_discount")
        self.assertEquals(discount.never_expires, False)
        self.assertEquals(discount.number_of_billing_cycles, 1)