Esempio n. 1
0
    def test_execute_transfer__do_not_allow_twice(self):
        from_user = user_factories.UserFactory(
            username='******',
            balance=150,
        )
        to_user = user_factories.UserFactory(
            username='******',
            balance=25,
        )
        transfer = factories.TransferFactory(
            from_user=from_user,
            to_user=to_user,
            quantity=50,
        )

        self.assertTrue(transfer.execute_transfer())
        self.assertFalse(transfer.execute_transfer())
Esempio n. 2
0
    def test_execute_transfer__negative(self):
        from_user = user_factories.UserFactory(
            username='******',
            balance=-250.33,
        )
        to_user = user_factories.UserFactory(
            username='******',
            balance=-1500.708,
        )
        transfer = factories.TransferFactory(
            from_user=from_user,
            to_user=to_user,
            quantity=285.49,
        )

        self.assertTrue(transfer.execute_transfer())
        self.assertEqual(from_user.get_balance(), -535.82)
        self.assertEqual(to_user.get_balance(), -1215.218)
Esempio n. 3
0
    def test_execute_transfer(self):
        from_user = user_factories.UserFactory(
            username='******',
            balance=150,
        )
        to_user = user_factories.UserFactory(
            username='******',
            balance=25,
        )
        transfer = factories.TransferFactory(
            from_user=from_user,
            to_user=to_user,
            quantity=50,
        )

        self.assertTrue(transfer.execute_transfer())
        self.assertEqual(from_user.get_balance(), 100)
        self.assertEqual(to_user.get_balance(), 75)
Esempio n. 4
0
 def test_same_origin_and_destiny(self):
     user = user_factories.UserFactory()
     self.assertRaisesRegex(
         exceptions.ValidationError,
         'It is not possible to make transfers to the same person who send '
         'the money.',
         factories.TransferFactory,
         from_user=user,
         to_user=user,
         quantity=10
     )
Esempio n. 5
0
    def test_get_balance__negative(self):
        user = factories.UserFactory(balance=-70.8)

        self.assertEqual(user.get_balance(), -70.8)
Esempio n. 6
0
    def test_get_balance__positive(self):
        user = factories.UserFactory(balance=1984.33)

        self.assertEqual(user.get_balance(), 1984.33)
Esempio n. 7
0
    def test_get_balance__default(self):
        user = factories.UserFactory()

        self.assertEqual(user.get_balance(), 0.0)
Esempio n. 8
0
    def test_str(self):
        user = factories.UserFactory(username='******')

        self.assertEqual(str(user), 'foo')