Ejemplo n.º 1
0
    def test_payment(self):
        outcome = Payment.create_payment(drawee=self.user.username,
                                         pledger=self.user2.username,
                                         amount=-125.0,
                                         room="test_payment",
                                         name="test_payment")

        self.assertEqual(outcome['matrix'].matrix, '{"t_user":{"t_user":125.0,"t_user2":0.0},'
                                                   '"t_user2":{"t_user":-125.0,"t_user2":0.0}}')
Ejemplo n.º 2
0
    def test_delete_payment(self):
        outcome = Payment.create_payment(drawee=self.user.username,
                                         pledger=self.user2.username,
                                         amount=-125.0,
                                         room="test_payment",
                                         name="test_payment")
        payment_id = outcome['payment'].id

        self.assertEqual(Payment.objects.count(), 1)

        Payment.delete_payment(payment_id)

        self.assertEqual(Payment.objects.count(), 0)
Ejemplo n.º 3
0
    def test_delete_payment_integrity_check(self):
        outcome = Payment.create_payment(drawee=self.user.username,
                                         pledger=self.user2.username,
                                         amount=-125.0,
                                         room="test_payment",
                                         name="test_payment")

        matrix = Room.objects.get(name="test_payment").matrix

        self.assertEqual(matrix, '{"t_user":{"t_user":125.0,"t_user2":0.0},'
                                 '"t_user2":{"t_user":-125.0,"t_user2":0.0}}')

        Payment.delete_payment_keep_integrity(outcome['payment'].id)

        matrix = Room.objects.get(name="test_payment").matrix
        self.assertEqual(matrix, '{"t_user":{"t_user":0.0,"t_user2":0.0},'
                                 '"t_user2":{"t_user":0.0,"t_user2":0.0}}')