def test_transaction_objects(self):
        """
		Test that the transact and transact_many methods work.
		"""

        account = Account.objects.get(pk=1)
        account.check_bal(force=True)
        # See that the balances are being updated correctly
        # and that the check_bal function works in force mode
        self.assertEquals(account.check_bal(), account.bal)

        # Make sure transactions are being added as soon as they are created
        cur_hist_length = len(account.history.all())
        new_transactions = autofixture.create(
            Transaction, 4, field_values={"amount": random_decimal_generator(), "user": account.user}
        )

        self.assertEquals(len(account.history.all()), cur_hist_length + 4)
    def test_P4A_confirmation(self):

        hash_info = [
            settings.P4A_MERCHANT_ID,
            random_text_generator(),
            random_decimal_generator(),
            settings.P4A_SECRET_KEY,
        ]
        digest = SHA256Hash(hash_info)

        # Check that no duplicate order ids are produced

        response = self.client.get(
            reverse("p4a_confirmation"),
            {
                "merchant": hash_info[0],
                "checkout": 364775,
                "amount": hash_info[2],
                "email": "*****@*****.**",
                "phone": "98349",
                "order": hash_info[1],
                "timestamp": int(time.time()),
                "digest": digest,
            },
        )

        # Confirm the server responded and created an object with the right digest.
        self.assertEquals(response.status_code, 200)
        self.assertTrue(CallBackNotification.objects.get(digest=digest))
        # Check that confirmational JSON token was produced
        self.assertEquals(ast.literal_eval(response.content), {"status": 1})

        hash_info = [
            settings.P4A_MERCHANT_ID,
            random_text_generator(),
            random_decimal_generator(),
            settings.P4A_SECRET_KEY,
        ]
        digest = SHA256Hash(hash_info)

        response = self.client.get(
            reverse("p4a_confirmation"),
            {
                "merchant": hash_info[0],
                "amount": hash_info[2],
                "order": hash_info[1],
                "timestamp": int(time.time()),
                "digest": digest,
            },
        )
        self.assertEquals(response.status_code, 200)
        self.assertTrue(CallBackNotification.objects.get(digest=digest))
        # Check that confirmational JSON token was produced
        self.assertEquals(ast.literal_eval(response.content), {"status": 1})

        response = self.client.get(
            reverse("p4a_confirmation"),
            {
                "merchant": hash_info[0],
                "amount": hash_info[2],
                "order": hash_info[1],
                "timestamp": "pie",
                "digest": digest,
            },
        )
        self.assertEquals(response.status_code, 200)
        # Check that error JSON token was produced
        self.assertEquals(ast.literal_eval(response.content), {"status": 0})