예제 #1
0
    def test_calculate_expenses_when_more_consumers(self):
        children = [Child(10, 5, 6), Child(5, 5, 5)]
        appliances = [Appliance(15)]
        self.room.calculate_expenses(children, appliances)

        expected = children[0].get_monthly_expense() + children[
            1].get_monthly_expense() + appliances[0].get_monthly_expense()

        self.assertEqual(expected, self.room.expenses)
예제 #2
0
    def test_room_calculate_expenses__expect_calculation_of_all_costs_for_one_month(
            self):
        self.room.children = [Child(5, 5, 5), Child(4, 6, 2)]
        appliances = [Fridge(), Laptop(), Stove(), TV()]
        self.room.calculate_expenses(self.room.children, appliances)

        expected_cost = 942
        actual_cost = self.room.expenses
        self.assertEqual(expected_cost, actual_cost)
예제 #3
0
    def test__calculate_expenses_when_two_consumers__expect_expenses_to_be_correct(
            self):
        appliances = [Child(1, 2, 3, 4)]
        children = [Child(5, 1, 2, 3)]

        self.room.calculate_expenses(appliances, children)
        expected = appliances[0].get_monthly_expense(
        ) + children[0].get_monthly_expense()

        self.assertEqual(expected, self.room.expenses)
예제 #4
0
def test_one():
    young_couple = YoungCouple("Johnsons", 150, 205)

    child1 = Child(5, 1, 2, 1)
    child2 = Child(3, 2)
    young_couple_with_children = YoungCoupleWithChildren("Peterson", 600, 520, child1, child2)

    everland.add_room(young_couple)
    everland.add_room(young_couple_with_children)

    print(everland.get_monthly_consumptions())
    print(everland.pay())
    print(everland.status())
예제 #5
0
def test_one():
    young_couple = YoungCouple("Johnsons", 150, 205)
    # young_couple_but_broke = YoungCouple("Jacksons", 50, 55)
    child_one = Child(5, 1, 2, 1)
    child_two = Child(3, 2)
    young_couple_with_children = YoungCoupleWithChildren("Peterson", 600, 520, child_one, child_two)

    everland.add_room(young_couple)
    everland.add_room(young_couple_with_children)
    # everland.add_room(young_couple_but_broke)
    # everland.add_room(young_couple)

    print(everland.get_monthly_consumptions())
    print(everland.pay())
    print(everland.status())
예제 #6
0
    def test__calculate_expenses_when_1_consumer__expect_expenses_to_be_correct(
            self):
        consumers = [Child(1, 2, 3, 4)]
        self.room.calculate_expenses(consumers)

        self.assertEqual(consumers[0].get_monthly_expense(),
                         self.room.expenses)
예제 #7
0
 def test_calculate_expenses(self):
     child = Child(20)
     room_one = Room('Ivanovi', 1500, 2)
     room_one.calculate_expenses(child)
     self.assertEqual(room_one.expenses, 600)
예제 #8
0
 def test_calculate_expenses_with_children(self):
     fridge = [Fridge()]
     child = [Child(2, 1, 2, 3)]
     self.room.calculate_expenses(fridge, child)
     self.assertEqual(276, self.room.expenses)
예제 #9
0
    young_couple_with_children = YoungCoupleWithChildren(
        "Peterson", 600, 520, child_one, child_two)

    everland.add_room(young_couple)
    everland.add_room(young_couple_with_children)

    print(everland.get_monthly_consumptions())
    print(everland.pay())
    print(everland.status())


Appliance(10).get_monthly_expense()
Fridge().get_monthly_expense()
Laptop().get_monthly_expense()
Stove().get_monthly_expense()
TV().get_monthly_expense()
Child(1, 2, 3)
AloneOld("BOB", 2)
AloneYoung("ROB", 2)
OldCouple("Bobby", 1, 2)
Room("Room", 2, 3)
YoungCouple("Pep", 20, 20)
YoungCoupleWithChildren("Bob", 10, 15, Child(1, 2, 3), Child(4, 5, 6))
Everland().add_room(Room("Room", 2, 3))
Everland().get_monthly_consumptions()
Everland().pay()
Everland().status()

if __name__ == "__main__":
    test_one()
예제 #10
0
 def test_room_calculate_expenses(self):
     appliances = [TV(), Laptop(), Fridge()] * self.room.members_count
     child1 = Child(5, 2, 3, 1)
     children = [child1]
     self.room.calculate_expenses(appliances, children)
     self.assertEqual(self.room.expenses, 552)
예제 #11
0
 def test_calculate_expenses(self):
     self.assertEqual(0, self.room.expenses)
     c1 = Child(5, 4, 1)
     expected = 300
     self.room.calculate_expenses([c1])
     self.assertEqual(expected, self.room.expenses)
예제 #12
0
from typing import ClassVar, List

from project.appliances.appliance import Appliance
from project.appliances.tv import TV
from project.appliances.fridge import Fridge
from project.appliances.laptop import Laptop
from project.rooms.room import Room
from project.people.child import Child


class YoungCoupleWithChildren(Room):
    _adults_count: ClassVar[int] = 2
    _default_room_cost: ClassVar[int] = 30
    _default_appliances: ClassVar[List[Appliance]] = [TV(), Fridge(), Laptop()]

    def __init__(self, family_name: str, salary1: float, salary2: float,
                 *children: Child) -> None:
        members_count = self._adults_count + len(children)
        super().__init__(family_name, salary1 + salary2, members_count)
        self.children = list(children)
        self.appliances = self._default_appliances * members_count
        self.calculate_expenses(self.children, self.appliances)


yc = YoungCoupleWithChildren('Test', 1000, 1000, Child(5), Child(5))
print(yc.room_cost)
예제 #13
0
    def test_calculate_expenses_when_1_consumer(self):
        child = [Child(10, 5, 6)]
        self.room.calculate_expenses(child)

        self.assertEqual(child[0].get_monthly_expense(), self.room.expenses)
예제 #14
0
from project.everland import Everland
from project.people.child import Child
from project.rooms.young_couple import YoungCouple
from project.rooms.young_couple_with_children import YoungCoupleWithChildren

everland = Everland()

young_couple = YoungCouple("Johnsons", 150, 205)
child1 = Child(5, 1, 2, 1)
child2 = Child(3, 2)
young_couple_with_children = YoungCoupleWithChildren("Peterson", 600, 520,
                                                     child1, child2)

everland.add_room(young_couple)
everland.add_room(young_couple_with_children)

print(everland.get_monthly_consumptions())
print(everland.pay())
print(everland.status())
예제 #15
0
 def test_calculate_expenses__when_one_child_and_one_appliance__expect_to_calculate_them(self):
     consumers = [Child(5, 2, 2), TV()]
     self.room.calculate_expenses(consumers)
     expect = consumers[0].get_monthly_expense() + consumers[1].get_monthly_expense()
     self.assertEqual(expect, self.room.expenses)
예제 #16
0
 def test_calculate_expenses__when_one_child__expect_to_calculate_them(self):
     consumers = [Child(5, 2, 2)]
     self.room.calculate_expenses(consumers)
     self.assertEqual(consumers[0].get_monthly_expense(), self.room.expenses)