예제 #1
0
 def test_create_spend_chart(self):
     self.food.deposit(900, "deposit")
     self.entertainment.deposit(900, "deposit")
     self.business.deposit(900, "deposit")
     self.food.withdraw(105.55)
     self.entertainment.withdraw(33.40)
     self.business.withdraw(10.99)
     actual = create_spend_chart([self.business, self.food, self.entertainment])
     expected = "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
     self.assertEqual(actual, expected, 'Expected different chart representation. Check that all spacing is exact.')
예제 #2
0
 def test_create_spend_chart(self):
     self.food.deposit(900, "deposit")
     self.entertainment.deposit(900, "deposit")
     self.business.deposit(900, "deposit")
     self.food.withdraw(105.55)
     self.entertainment.withdraw(33.40)
     self.business.withdraw(10.99)
     actual = create_spend_chart([self.business, self.food, self.entertainment])
     #There's a mistake in the original string, so I've made a copy and modified it.The % spent on Business Category is 7. Therefore also reach the 10| tick, since 7 is nearer to 10 than 0.
     #expected = "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
     expected = "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10| o  o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
     self.assertEqual(actual, expected, 'Expected different chart representation. Check that all spacing is exact.')
예제 #3
0
 def test_create_spend_chart(self):
     self.maxDiff = None
     self.food.deposit(900, "deposit")
     self.entertainment.deposit(900, "deposit")
     self.business.deposit(900, "deposit")
     self.food.withdraw(105.55)
     self.entertainment.withdraw(33.40)
     self.business.withdraw(10.99)
     actual = create_spend_chart(
         [self.business, self.food, self.entertainment])
     expected = (""
                 "Percentage spent by category\n"
                 "100|          \n"
                 " 90|          \n"
                 " 80|          \n"
                 " 70|    o     \n"
                 " 60|    o     \n"
                 " 50|    o     \n"
                 " 40|    o     \n"
                 " 30|    o     \n"
                 " 20|    o  o  \n"
                 " 10|    o  o  \n"
                 "  0| o  o  o  \n"
                 "    ----------\n"
                 "     B  F  E  \n"
                 "     u  o  n  \n"
                 "     s  o  t  \n"
                 "     i  d  e  \n"
                 "     n     r  \n"
                 "     e     t  \n"
                 "     s     a  \n"
                 "     s     i  \n"
                 "           n  \n"
                 "           m  \n"
                 "           e  \n"
                 "           n  \n"
                 "           t  ")
     self.assertEqual(
         actual,
         expected,
         "Expected different chart representation. "
         "Check that all spacing is exact.",
     )
예제 #4
0
# This entrypoint file to be used in development. Start by reading README.md

import budget
from budget import create_spend_chart
from unittest import main

food = budget.Category("Food")
food.deposit(1000, "initial deposit")
food.withdraw(10.15, "groceries")
food.withdraw(15.89, "restaurant and more food for dessert")
print(food.get_balance())
clothing = budget.Category("Clothing")
food.transfer(50, clothing)
clothing.withdraw(25.55)
clothing.withdraw(100)
auto = budget.Category("Auto")
auto.deposit(1000, "initial deposit")
auto.withdraw(15)

print(food)
print(clothing)

print(create_spend_chart([food, clothing, auto]))

# Run unit tests automatically
main(module='test_module', exit=False)
예제 #5
0
food.deposit(1000, "initial deposit")
food.withdraw(10.15, "groceries")
food.withdraw(15.89, "restaurant and more food for dessert")
print(food.get_balance())
clothing = budget.Category("Clothing")
food.transfer(50, clothing)
clothing.withdraw(25.55)
clothing.withdraw(100)
auto = budget.Category("Auto")
auto.deposit(1000, "initial deposit")
auto.withdraw(15)

print(food)
print(clothing)

print(create_spend_chart([food, clothing, auto]))
food = budget.Category("Food")
entertainment = budget.Category("Entertainment")
business = budget.Category("Business")
food.deposit(900, "deposit")
entertainment.deposit(900, "deposit")
business.deposit(900, "deposit")
food.withdraw(105.55)
entertainment.withdraw(33.40)
business.withdraw(10.99)
print(create_spend_chart([business, food, entertainment]))
print(
    "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
)

# Run unit tests automatically
예제 #6
0
# This entrypoint file to be used in development. Start by reading README.md
import budget
from budget import create_spend_chart
from unittest import main

food = budget.Category("Food")
food.deposit(1000, "initial deposit")
food.withdraw(10.15, "groceries")
food.withdraw(15.89, "restaurant and more food for dessert")
print(food.get_balance())
clothing = budget.Category("Clothing")
food.transfer(50, clothing)
clothing.withdraw(25.55)
clothing.withdraw(100)
business = budget.Category("Business")
business.deposit(1000, "initial deposit")
business.withdraw(15)

print(food)
print(clothing)

print(create_spend_chart([food, clothing, business]))

# Run unit tests automatically
#main(module='test_alg', exit=False)
예제 #7
0
Clothes.withdraw(800.00, 'bought clothes for work')
Clothes.withdraw(200.00, 'work uniform')
Clothes.withdraw(150.00, 'bought new sneakers')

Auto = Category('Auto')
Auto.deposit(10000.00, 'initial deposit')
Auto.withdraw(5000.00, 'repair after accident')
Auto.withdraw(500.00, 'new bumper plates')
Auto.withdraw(300.00, 'new tires')
#new_balance = get_deposit_sum(food)
#old_balance = new_balance - get_withdraw_sum(food)

#print(food)
category_list = [food, Clothes, Auto]

for item in category_list:
    print_spend_chart(create_spend_chart(item))
    print('')
    print('')

'''
for line in fuck_around[1:11]:
    print(line)
for line in shit_around[1:11]:
    print(line)
'''




예제 #8
0
# This entrypoint file to be used in development. Start by reading README.md
import budget
from budget import create_spend_chart
from unittest import main

food = budget.Category("Food")
entertainment = budget.Category("Entertainment")
business = budget.Category("Business")

food.deposit(900, "deposit")
entertainment.deposit(900, "deposit")
business.deposit(900, "deposit")
food.withdraw(105.55)
entertainment.withdraw(33.40)
business.withdraw(10.99)
print(create_spend_chart([business, food, entertainment]))
print(
    "100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
)
# Run unit tests automatically
main(module='test_module', exit=False)
예제 #9
0
파일: budget.py 프로젝트: Nicodona/Zuri
    percent.clear()
    return output


#PLEASE THIS IS THE MAIN APP
import budget
from budget import create_spend_chart
from unittest import main

food = budget.Category("Food")
food.deposit(10000, "initial deposit")
food.withdraw(2000.35, "groceries")
food.withdraw(1500.50, "eatery and more food for friends")
print(food.get_balance())

clothing = budget.Category("Clothing")
food.transfer(1000, clothing)
clothing.withdraw(500.25)
clothing.withdraw(400.75)

entertainment = budget.Category("Entertainment")
food.transfer(1500, entertainment)
entertainment.deposit(3500, "initial deposit")
entertainment.withdraw(2000)

print(food)
print(clothing)
print(entertainment)

print(create_spend_chart([food, clothing, entertainment]))
예제 #10
0
# This entrypoint file to be used in development. Start by reading README.md
import budget
from budget import create_spend_chart
from unittest import main

entertainment = budget.Category("Entertainment")
#print(food)
#print(clothing)
food = budget.Category("Food")
food.deposit(90, "deposit")
food.withdraw(10.67, "milk, cereal, eggs, bacon, bread")
#food.transfer(5656512.67, entertainment)
#print(food)
print(
    "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
)
create_spend_chart([food, entertainment])
#print(create_spend_chart([food, clothing, auto]))

# Run unit tests automatically
#main(module='test_module', exit=False)
예제 #11
0
파일: main.py 프로젝트: rupayanr/python
import budget
from budget import create_spend_chart
from budget import Category

food = Category("Food")
food.deposit(4000, "deposit")
food.withdraw(2000, "bbq nation")

petrol = Category("Petrol")
petrol.deposit(10000, "deposit")
petrol.withdraw(5000, "petrol")

print(food)
print(petrol)

create_spend_chart([food, petrol])
예제 #12
0
clothing.withdraw(25.55)
clothing.withdraw(100)
auto = budget.Category("Auto")
auto.deposit(1000, "initial deposit")
auto.withdraw(15)
print(auto.get_balance())

print(food)
print(clothing)

#print(str(food.get_total_withdrawals()))

print(create_spend_chart([food, clothing, auto]))
'''
# Run unit tests automatically
main(module='test_module', exit=False)

food = budget.Category("Food")
entertainment = budget.Category("Entertainment")
business = budget.Category("Business")
food.deposit(900, "deposit")
entertainment.deposit(900, "deposit")
business.deposit(900, "deposit")
food.withdraw(105.55)
entertainment.withdraw(33.40)
business.withdraw(10.99)
actual = create_spend_chart([business, food, entertainment])
expected = "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "
#print(actual)
#print('********************')
#print(expected)