예제 #1
0
class AllocationsTestCase(TestCase):
    def setUp(self):
        self.allocations = Allocations()

    def test_have_default_total_of_zero(self):
        self.assertEqual(D('0.00'), self.allocations.total)

    def test_has_items_interface(self):
        self.allocations.add('A', D('10.00'))

        for code, amount in self.allocations.items():
            self.assertEqual('A', code)
            self.assertEqual(D('10.00'), amount)

    def test_allow_items_to_be_removed(self):
        self.allocations.add('A', D('10.00'))
        self.assertEqual(D('10.00'), self.allocations.total)
        self.allocations.remove('A')
        self.assertEqual(D('0.00'), self.allocations.total)

    def test_serialize(self):
        self.allocations.add('A', D('10.00'))
        self.allocations.add('B', D('12.00'))

        serialized = Allocations.serialize(self.allocations)
        self.assertEqual(serialized, '{"A": "10.00", "B": "12.00"}')

    def test_deserialize(self):
        obj = Allocations.deserialize('{"C": "10.00", "D": "12.00"}')
        items = list(obj.items())
        self.assertCountEqual(items, [('C', D('10.00')), ('D', D('12.00'))])
class AllocationsTestCase(TestCase):

    def setUp(self):
        self.allocations = Allocations()

    def test_have_default_total_of_zero(self):
        self.assertEqual(D('0.00'), self.allocations.total)

    def test_has_items_interface(self):
        self.allocations.add('A', D('10.00'))

        for code, amount in self.allocations.items():
            self.assertEqual('A', code)
            self.assertEqual(D('10.00'), amount)

    def test_allow_items_to_be_removed(self):
        self.allocations.add('A', D('10.00'))
        self.assertEqual(D('10.00'), self.allocations.total)
        self.allocations.remove('A')
        self.assertEqual(D('0.00'), self.allocations.total)

    def test_serialize(self):
        self.allocations.add('A', D('10.00'))
        self.allocations.add('B', D('12.00'))

        serialized = Allocations.serialize(self.allocations)
        self.assertEqual(serialized, '{"A": "10.00", "B": "12.00"}')

    def test_deserialize(self):
        obj = Allocations.deserialize('{"C": "10.00", "D": "12.00"}')
        items = list(obj.items())
        self.assertCountEqual(items, [('C', D('10.00')), ('D', D('12.00'))])
예제 #3
0
class TestAllocations(TestCase):
    def setUp(self):
        self.allocations = Allocations()

    def test_have_default_total_of_zero(self):
        self.assertEqual(D('0.00'), self.allocations.total)

    def test_has_items_interface(self):
        self.allocations.add('A', D('10.00'))

        for code, amount in self.allocations.items():
            self.assertEqual('A', code)
            self.assertEqual(D('10.00'), amount)

    def test_allow_items_to_be_removed(self):
        self.allocations.add('A', D('10.00'))
        self.assertEqual(D('10.00'), self.allocations.total)
        self.allocations.remove('A')
        self.assertEqual(D('0.00'), self.allocations.total)
예제 #4
0
 def set_account_allocations(self, allocations):
     return self.checkout_session._set('accounts', 'allocations',
                                       Allocations.serialize(allocations))
예제 #5
0
 def get_account_allocations(self):
     allocation_data = self.checkout_session._get('accounts', 'allocations',
                                                  '{}')
     return Allocations.deserialize(allocation_data)
 def setUp(self):
     self.allocations = Allocations()
 def test_deserialize(self):
     obj = Allocations.deserialize('{"C": "10.00", "D": "12.00"}')
     items = list(obj.items())
     self.assertCountEqual(items, [('C', D('10.00')), ('D', D('12.00'))])
    def test_serialize(self):
        self.allocations.add('A', D('10.00'))
        self.allocations.add('B', D('12.00'))

        serialized = Allocations.serialize(self.allocations)
        self.assertEqual(serialized, '{"A": "10.00", "B": "12.00"}')
예제 #9
0
 def set_account_allocations(self, allocations):
     return self.checkout_session._set('accounts', 'allocations', Allocations.serialize(allocations))
예제 #10
0
 def get_account_allocations(self):
     allocation_data = self.checkout_session._get('accounts', 'allocations', '{}')
     return Allocations.deserialize(allocation_data)
예제 #11
0
 def setUp(self):
     self.allocations = Allocations()
예제 #12
0
 def test_deserialize(self):
     obj = Allocations.deserialize('{"C": "10.00", "D": "12.00"}')
     items = list(obj.items())
     self.assertCountEqual(items, [('C', D('10.00')), ('D', D('12.00'))])
예제 #13
0
    def test_serialize(self):
        self.allocations.add('A', D('10.00'))
        self.allocations.add('B', D('12.00'))

        serialized = Allocations.serialize(self.allocations)
        self.assertEqual(serialized, '{"A": "10.00", "B": "12.00"}')
예제 #14
0
파일: views.py 프로젝트: SpivEgin/devenv
 def get_account_allocations(self):
     return self.checkout_session._get('accounts', 'allocations',
                                       Allocations())
예제 #15
0
 def set_account_allocations(self, allocations):
     return self.checkout_session._set("accounts", "allocations",
                                       Allocations.serialize(allocations))
예제 #16
0
 def get_account_allocations(self):
     allocation_data = self.checkout_session._get("accounts", "allocations",
                                                  "{}")
     return Allocations.deserialize(allocation_data)