def test_payday_doesnt_move_money_from_a_suspended_payin_account(charge_on_balanced):
    charge_on_balanced.return_value = (Decimal('10.00'), Decimal('0.68'), None)
    tips = testing.setup_tips(('buz', 'bar', '6.00', True, True))  # under $10!
    with testing.load(*tips) as context:
        Payday(context.db).run()
        actual = context.diff(compact=True)
        assert actual == {"paydays": [1,0,0]}, actual
Esempio n. 2
0
def test_payday_doesnt_move_money_from_a_suspicious_account(charge_on_balanced):
    charge_on_balanced.return_value = (Decimal('10.00'), Decimal('0.68'), None)
    tips = testing.setup_tips(('buz', 'bar', '6.00', True, True))  # under $10!
    with testing.load(*tips) as context:
        Payday(context.db).run()
        actual = context.diff(compact=True)
        assert actual == {"paydays": [1,0,0]}, actual
Esempio n. 3
0
def test_get_chart_of_giving_handles_a_non_standard_amount():
    tip = ("foo", "bar", "5.37", True)
    expected = ( [[-1, 1, Decimal('5.37'), 1.0, Decimal('1')]]
               , 1.0, Decimal('5.37')
                )
    with testing.setup_tips(tip):
        actual = gittip.get_chart_of_giving('bar')
        assert actual == expected, actual
Esempio n. 4
0
def test_get_chart_of_giving_handles_a_tip():
    tip = ("foo", "bar", "3.00", True)
    expected = ( [[Decimal('3.00'), 1, Decimal('3.00'), 1.0, Decimal('1')]]
               , 1.0, Decimal('3.00')
                )
    with testing.setup_tips(tip):
        actual = gittip.get_chart_of_giving('bar')
        assert actual == expected, actual
def test_payday_moves_money(charge_on_balanced):
    charge_on_balanced.return_value = (Decimal('10.00'), Decimal('0.68'), None)
    tips = testing.setup_tips(('buz', 'bar', '6.00', True))  # under $10!
    with testing.load(*tips) as context:
        Payday(context.db).run()
        expected = [ {"id": "buz", "balance": Decimal('3.32')}
                   , {"id": "bar", "balance": Decimal('6.00')}
                    ]
        actual = context.diff()['participants']['updates']
        assert actual == expected, actual
Esempio n. 6
0
def test_get_chart_of_giving_ignores_missing_cc():
    tips = [ ("foo", "bar", "1.00", True)
           , ("baz", "bar", "3.00", None)
            ]
    expected = ( [[Decimal('1.00'), 1L, Decimal('1.00'), 1, Decimal('1')]]
               , 1.0, Decimal('1.00')
                )
    with testing.setup_tips(*tips):
        actual = gittip.get_chart_of_giving('bar')
        assert actual == expected, actual
Esempio n. 7
0
def test_payday_moves_money(charge_on_balanced):
    charge_on_balanced.return_value = (Decimal('10.00'), Decimal('0.68'), None)
    tips = testing.setup_tips(('buz', 'bar', '6.00', True))  # under $10!
    with testing.load(*tips) as context:
        Payday(context.db).run()
        expected = [ {"id": "buz", "balance": Decimal('3.32')}
                   , {"id": "bar", "balance": Decimal('6.00')}
                    ]
        actual = context.diff()['participants']['updates']
        assert actual == expected, actual
def test_payday_does_stuff(charge_on_balanced):
    charge_on_balanced.return_value = (Decimal('10.00'), Decimal('0.68'), None)
    tips = testing.setup_tips(('buz', 'bar', '6.00', True))  # under $10!
    with testing.load(*tips) as context:
        Payday(context.db).run()
        expected = { 'exchanges': [1, 0, 0]
                   , 'participants': [0, 2, 0]
                   , 'paydays': [1, 0, 0]
                   , 'transfers': [1, 0, 0]
                    }
        actual = context.diff(compact=True)
        assert actual == expected, actual
Esempio n. 9
0
def test_get_chart_of_giving_handles_multiple_tips():
    tips = [ ("foo", "bar", "1.00", True)
           , ("baz", "bar", "3.00", True)
            ]
    expected = ( [ [Decimal('1.00'), 1L, Decimal('1.00'), 0.5, Decimal('0.25')]
                 , [Decimal('3.00'), 1L, Decimal('3.00'), 0.5, Decimal('0.75')]
                  ]
               , 2.0, Decimal('4.00')
                )
    with testing.setup_tips(*tips):
        actual = gittip.get_chart_of_giving('bar')
        assert actual == expected, actual
Esempio n. 10
0
def test_payday_does_stuff(charge_on_balanced):
    charge_on_balanced.return_value = (Decimal('10.00'), Decimal('0.68'), None)
    tips = testing.setup_tips(('buz', 'bar', '6.00', True))  # under $10!
    with testing.load(*tips) as context:
        Payday(context.db).run()
        expected = { 'exchanges': [1, 0, 0]
                   , 'participants': [0, 2, 0]
                   , 'paydays': [1, 0, 0]
                   , 'transfers': [1, 0, 0]
                    }
        actual = context.diff(compact=True)
        assert actual == expected, actual
Esempio n. 11
0
def test_get_chart_of_giving_handles_no_tips():
    expected = ([], 0.0, Decimal('0.00'))
    with testing.setup_tips():
        actual = gittip.get_chart_of_giving('foo')
        assert actual == expected, actual
Esempio n. 12
0
def setup(*a):
    return testing.load(*testing.setup_tips(*a))