diff --git a/.vscode/easycode.ignore b/.vscode/easycode.ignore new file mode 100644 index 000000000..84722bf8a --- /dev/null +++ b/.vscode/easycode.ignore @@ -0,0 +1,13 @@ +node_modules/ +dist/ +vendor/ +cache/ +.*/ +*.min.* +*.test.* +*.spec.* +*.bundle.* +*.bundle-min.* +*.*.js +*.*.ts +*.log \ No newline at end of file diff --git a/engine/__init__.py b/__init__.py similarity index 100% rename from engine/__init__.py rename to __init__.py diff --git a/car.py b/car.py deleted file mode 100644 index f7b980a1b..000000000 --- a/car.py +++ /dev/null @@ -1,10 +0,0 @@ -from abc import ABC, abstractmethod - - -class Car(ABC): - def __init__(self, last_service_date): - self.last_service_date = last_service_date - - @abstractmethod - def needs_service(self): - pass diff --git a/car_Factory.py b/car_Factory.py new file mode 100644 index 000000000..9225bb1e5 --- /dev/null +++ b/car_Factory.py @@ -0,0 +1,56 @@ +#importing necessary libraries +from car_Module import Serviceable, Car +from car_Module.components.battery import Battery, NubbinBattery, SpindlerBattery +from car_Module.components.engine import Engine, CapuletEngine, SternmanEngine, WilloughbyEngine +from car_Module.components.tire import Tire, CarriganTire, OctoprimeTire +from typing import List +from datetime import date + + +#CarFactory class to create all available models +class CarFactory: + #create_calliope method + #calliope uses Capulet engine + #calliope uses Spindler battery + def create_calliope(current_date:date, last_service_date: date, current_mileage:int, last_service_mileage:int, tire_wear:List[float]) -> Car: + calliope_engine = CapuletEngine(current_mileage=current_mileage,last_service_mileage=last_service_mileage) + calliope_battery = SpindlerBattery(current_date=current_date,last_service_date=last_service_date) + tire = CarriganTire(tire_wear=tire_wear) + return Car(engine=calliope_engine,battery=calliope_battery,tire=tire) + + #create_glissade method + #calliope uses Willoughby engine + #calliope uses Spindler battery + def create_glissade(current_date:date, last_service_date: date, current_mileage:int, last_service_mileage:int, tire_wear:List[float]) -> Car: + glissade_engine = WilloughbyEngine(current_mileage=current_mileage,last_service_mileage=last_service_mileage) + glissade_battery = SpindlerBattery(current_date=current_date,last_service_date=last_service_date) + tire = CarriganTire(tire_wear=tire_wear) + return Car(engine=glissade_engine,battery=glissade_battery,tire=tire) + + #create_palindrome method + #calliope uses Sternman Engine + #calliope uses Spindler battery + def create_palindrome(current_date:date, last_service_date: date, warning_light_on:bool, tire_wear:List[float]) -> Car : + palindrome_engine = SternmanEngine(warning_light_is_on=warning_light_on) + palindrome_battery = SpindlerBattery(current_date=current_date,last_service_date=last_service_date) + tire = OctoprimeTire(tire_wear=tire_wear) + return Car(engine=palindrome_engine,battery=palindrome_battery,tire=tire) + + #create_rorschach method + #calliope uses Willoughby engine + #calliope uses Nubbin battery + def create_rorschach(current_date:date, last_service_date: date, current_mileage:int, last_service_mileage:int, tire_wear:List[float]) -> Car : + rorschach_engine = WilloughbyEngine(current_mileage=current_mileage,last_service_mileage=last_service_mileage) + rorschach_battery = NubbinBattery(current_date=current_date,last_service_date=last_service_date) + tire = CarriganTire(tire_wear=tire_wear) + return Car(engine=rorschach_engine,battery=rorschach_battery,tire=tire) + + #create_thovex method + #calliope uses Capulet engine + #calliope uses Nubbin battery + def create_thovex(current_date:date, last_service_date: date, current_mileage:int, last_service_mileage:int, tire_wear:List[float]) -> Car : + thovex_engine = CapuletEngine(current_mileage=current_mileage,last_service_mileage=last_service_mileage) + thovex_battery = NubbinBattery(current_date=current_date,last_service_date=last_service_date) + tire = OctoprimeTire(tire_wear=tire_wear) + return Car(engine=thovex_engine,battery=thovex_battery) + \ No newline at end of file diff --git a/car_Module/__init__.py b/car_Module/__init__.py new file mode 100644 index 000000000..efbb44a4c --- /dev/null +++ b/car_Module/__init__.py @@ -0,0 +1,3 @@ +#import necessary libraries +from .serviceable_Interface import Serviceable +from .car import Car \ No newline at end of file diff --git a/car_Module/car.py b/car_Module/car.py new file mode 100644 index 000000000..6ee0e300b --- /dev/null +++ b/car_Module/car.py @@ -0,0 +1,13 @@ +#import necessary libraries +from .serviceable_Interface import Serviceable +from .components.battery.battery_Interface import Battery +from .components.engine.engine_Interface import Engine + +#Car class object with engine/battery and service status +class Car(Serviceable): + def __init__(self, engine:Engine, battery: Battery): + self.engine = engine + self.battery = battery + + def needs_service(self) -> bool: + return self.engine.needs_service() or self.battery.needs_service() \ No newline at end of file diff --git a/car_Module/components/battery/__init__.py b/car_Module/components/battery/__init__.py new file mode 100644 index 000000000..7c93a0f6f --- /dev/null +++ b/car_Module/components/battery/__init__.py @@ -0,0 +1,3 @@ +from .nubbin_Battery import NubbinBattery +from .spindler_Battery import SpindlerBattery +from .battery_Interface import Battery \ No newline at end of file diff --git a/car_Module/components/battery/battery_Interface.py b/car_Module/components/battery/battery_Interface.py new file mode 100644 index 000000000..723c36d18 --- /dev/null +++ b/car_Module/components/battery/battery_Interface.py @@ -0,0 +1,6 @@ +from abc import ABC, abstractmethod + +class Battery(ABC): + @abstractmethod + def needs_service() -> bool: + pass \ No newline at end of file diff --git a/car_Module/components/battery/nubbin_Battery.py b/car_Module/components/battery/nubbin_Battery.py new file mode 100644 index 000000000..759aec316 --- /dev/null +++ b/car_Module/components/battery/nubbin_Battery.py @@ -0,0 +1,12 @@ +from .battery_Interface import Battery +from datetime import date + +#Nubbin battery class +class NubbinBattery(Battery): + def __init__(self, current_date :date, last_service_date:date ): + self.current_date = current_date + self.last_service_date = last_service_date + + def needs_service(self) ->bool: + years = (self.current_date - self.last_service_date).days / 365.0 + return years > 4 \ No newline at end of file diff --git a/car_Module/components/battery/spindler_Battery.py b/car_Module/components/battery/spindler_Battery.py new file mode 100644 index 000000000..d7f4d6f0c --- /dev/null +++ b/car_Module/components/battery/spindler_Battery.py @@ -0,0 +1,12 @@ +from .battery_Interface import Battery +from datetime import date + +#Spindler battery class +class SpindlerBattery(Battery): + def __init__(self, current_date :date, last_service_date:date ): + self.current_date = current_date + self.last_service_date = last_service_date + + def needs_service(self) -> bool: + years = (self.current_date - self.last_service_date).days / 365.0 + return years > 3 \ No newline at end of file diff --git a/car_Module/components/engine/__init__.py b/car_Module/components/engine/__init__.py new file mode 100644 index 000000000..c3d51ac2c --- /dev/null +++ b/car_Module/components/engine/__init__.py @@ -0,0 +1,4 @@ +from .engine_Interface import Engine +from .capulet_Engine import CapuletEngine +from .sternman_Engine import SternmanEngine +from .willoughby_Engine import WilloughbyEngine \ No newline at end of file diff --git a/car_Module/components/engine/capulet_Engine.py b/car_Module/components/engine/capulet_Engine.py new file mode 100644 index 000000000..e3f94650a --- /dev/null +++ b/car_Module/components/engine/capulet_Engine.py @@ -0,0 +1,10 @@ +from .engine_Interface import Engine + + +class CapuletEngine(Engine): + def __init__(self, current_mileage :int, last_service_mileage:int ): + self.current_mileage = current_mileage + self.last_service_mileage = last_service_mileage + + def needs_service(self) ->bool: + return self.current_mileage - self.last_service_mileage > 30000 \ No newline at end of file diff --git a/car_Module/components/engine/engine_Interface.py b/car_Module/components/engine/engine_Interface.py new file mode 100644 index 000000000..85abd419b --- /dev/null +++ b/car_Module/components/engine/engine_Interface.py @@ -0,0 +1,6 @@ +from abc import ABC, abstractmethod + +class Engine(ABC): + @abstractmethod + def needs_service() -> bool: + pass \ No newline at end of file diff --git a/car_Module/components/engine/sternman_Engine.py b/car_Module/components/engine/sternman_Engine.py new file mode 100644 index 000000000..830e84c4f --- /dev/null +++ b/car_Module/components/engine/sternman_Engine.py @@ -0,0 +1,9 @@ +from .engine_Interface import Engine + + +class SternmanEngine(Engine): + def __init__(self, warning_light_is_on :bool): + self.warning_light_is_on = warning_light_is_on + + def needs_service(self) ->bool: + return self.warning_light_is_on \ No newline at end of file diff --git a/car_Module/components/engine/willoughby_Engine.py b/car_Module/components/engine/willoughby_Engine.py new file mode 100644 index 000000000..efa3e6357 --- /dev/null +++ b/car_Module/components/engine/willoughby_Engine.py @@ -0,0 +1,10 @@ +from .engine_Interface import Engine + + +class WilloughbyEngine(Engine): + def __init__(self, current_mileage :int, last_service_mileage:int ): + self.current_mileage = current_mileage + self.last_service_mileage = last_service_mileage + + def needs_service(self) ->bool: + return self.current_mileage - self.last_service_mileage > 60000 \ No newline at end of file diff --git a/car_Module/components/tire/__init__.py b/car_Module/components/tire/__init__.py new file mode 100644 index 000000000..2176b5abb --- /dev/null +++ b/car_Module/components/tire/__init__.py @@ -0,0 +1,3 @@ +from .tire_Interface import Tire +from .carrigan_Tire import CarriganTire +from .octoprime_Tire import OctoprimeTire \ No newline at end of file diff --git a/car_Module/components/tire/carrigan_Tire.py b/car_Module/components/tire/carrigan_Tire.py new file mode 100644 index 000000000..46a7bd0c3 --- /dev/null +++ b/car_Module/components/tire/carrigan_Tire.py @@ -0,0 +1,12 @@ +from car_Module.components.tire.tire_Interface import Tire +from typing import List + +class CarriganTire(Tire): + def __init__(self, tire_wear :List[float]): + self.tire_wear = tire_wear + + def needs_service(self) ->bool: + for value in self.tire_wear : + if value >= 0.9: + return True + return False \ No newline at end of file diff --git a/car_Module/components/tire/octoprime_Tire.py b/car_Module/components/tire/octoprime_Tire.py new file mode 100644 index 000000000..f31a4e769 --- /dev/null +++ b/car_Module/components/tire/octoprime_Tire.py @@ -0,0 +1,9 @@ +from car_Module.components.tire.tire_Interface import Tire +from typing import List + +class OctoprimeTire(Tire): + def __init__(self, tire_wear :List[float]): + self.tire_wear = tire_wear + + def needs_service(self) ->bool: + return sum(self.tire_wear) >= 3 \ No newline at end of file diff --git a/car_Module/components/tire/tire_Interface.py b/car_Module/components/tire/tire_Interface.py new file mode 100644 index 000000000..4ac2fcc60 --- /dev/null +++ b/car_Module/components/tire/tire_Interface.py @@ -0,0 +1,8 @@ +from abc import ABC, abstractmethod +from typing import List + + +class Tire(ABC): + @abstractmethod + def needs_service() -> bool: + pass \ No newline at end of file diff --git a/car_Module/serviceable_Interface.py b/car_Module/serviceable_Interface.py new file mode 100644 index 000000000..fd66ef88d --- /dev/null +++ b/car_Module/serviceable_Interface.py @@ -0,0 +1,8 @@ +#import necessary libraries +from abc import ABC, abstractmethod + +#Serviceable abstraction method +class Serviceable(ABC): + @abstractmethod + def needs_service() -> bool: + pass \ No newline at end of file diff --git a/engine/capulet_engine.py b/engine/capulet_engine.py deleted file mode 100644 index 69a2f3319..000000000 --- a/engine/capulet_engine.py +++ /dev/null @@ -1,13 +0,0 @@ -from abc import ABC - -from car import Car - - -class CapuletEngine(Car, ABC): - def __init__(self, last_service_date, current_mileage, last_service_mileage): - super().__init__(last_service_date) - self.current_mileage = current_mileage - self.last_service_mileage = last_service_mileage - - def engine_should_be_serviced(self): - return self.current_mileage - self.last_service_mileage > 30000 diff --git a/engine/model/calliope.py b/engine/model/calliope.py deleted file mode 100644 index 1dd3da56d..000000000 --- a/engine/model/calliope.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.capulet_engine import CapuletEngine - - -class Calliope(CapuletEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 2) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/glissade.py b/engine/model/glissade.py deleted file mode 100644 index e1b16ad27..000000000 --- a/engine/model/glissade.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.willoughby_engine import WilloughbyEngine - - -class Glissade(WilloughbyEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 2) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/palindrome.py b/engine/model/palindrome.py deleted file mode 100644 index 590864bc8..000000000 --- a/engine/model/palindrome.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.sternman_engine import SternmanEngine - - -class Palindrome(SternmanEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 4) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/rorschach.py b/engine/model/rorschach.py deleted file mode 100644 index b9eedc91d..000000000 --- a/engine/model/rorschach.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.willoughby_engine import WilloughbyEngine - - -class Rorschach(WilloughbyEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 4) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/model/thovex.py b/engine/model/thovex.py deleted file mode 100644 index eac5707f0..000000000 --- a/engine/model/thovex.py +++ /dev/null @@ -1,12 +0,0 @@ -from datetime import datetime - -from engine.capulet_engine import CapuletEngine - - -class Thovex(CapuletEngine): - def needs_service(self): - service_threshold_date = self.last_service_date.replace(year=self.last_service_date.year + 4) - if service_threshold_date < datetime.today().date() or self.engine_should_be_serviced(): - return True - else: - return False diff --git a/engine/sternman_engine.py b/engine/sternman_engine.py deleted file mode 100644 index 72d8b5ab3..000000000 --- a/engine/sternman_engine.py +++ /dev/null @@ -1,15 +0,0 @@ -from abc import ABC - -from car import Car - - -class SternmanEngine(Car, ABC): - def __init__(self, last_service_date, warning_light_is_on): - super().__init__(last_service_date) - self.warning_light_is_on = warning_light_is_on - - def engine_should_be_serviced(self): - if self.warning_light_is_on: - return True - else: - return False diff --git a/engine/willoughby_engine.py b/engine/willoughby_engine.py deleted file mode 100644 index e5e0dc581..000000000 --- a/engine/willoughby_engine.py +++ /dev/null @@ -1,13 +0,0 @@ -from abc import ABC - -from car import Car - - -class WilloughbyEngine(Car, ABC): - def __init__(self, last_service_date, current_mileage, last_service_mileage): - super().__init__(last_service_date) - self.current_mileage = current_mileage - self.last_service_mileage = last_service_mileage - - def engine_should_be_serviced(self): - return self.current_mileage - self.last_service_mileage > 60000 diff --git a/engine/model/__init__.py b/test/test_Battery/__init__.py similarity index 100% rename from engine/model/__init__.py rename to test/test_Battery/__init__.py diff --git a/test/test_Battery/test_NubbinBattery.py b/test/test_Battery/test_NubbinBattery.py new file mode 100644 index 000000000..72efaab52 --- /dev/null +++ b/test/test_Battery/test_NubbinBattery.py @@ -0,0 +1,16 @@ +import unittest +from car_Module.components.battery import NubbinBattery +from datetime import date + +class TestNubbinBattery(unittest.TestCase): + def test_needs_service_true_case(self): + current_date = date.today() + last_service_date = current_date.replace(year=current_date.year-5) + nubbin = NubbinBattery(current_date,last_service_date) + self.assertTrue(nubbin.needs_service()) + + def test_needs_service_false_case(self): + current_date = date.today() + last_service_date = current_date.replace(year=current_date.year-1) + nubbin = NubbinBattery(current_date,last_service_date) + self.assertFalse(nubbin.needs_service()) \ No newline at end of file diff --git a/test/test_Battery/test_SpindlerBattery.py b/test/test_Battery/test_SpindlerBattery.py new file mode 100644 index 000000000..8aa9a343e --- /dev/null +++ b/test/test_Battery/test_SpindlerBattery.py @@ -0,0 +1,16 @@ +import unittest +from car_Module.components.battery import SpindlerBattery +from datetime import date + +class TestSpindlerBattery(unittest.TestCase): + def test_check_needs_service_true_case(self): + current_date = date.today() + last_service_date = current_date.replace(year=current_date.year-4) + nubbin = SpindlerBattery(current_date,last_service_date) + self.assertTrue(nubbin.needs_service()) + + def test_check_needs_service_false_case(self): + current_date = date.today() + last_service_date = current_date.replace(year=current_date.year-1) + nubbin = SpindlerBattery(current_date,last_service_date) + self.assertFalse(nubbin.needs_service()) \ No newline at end of file diff --git a/test/test_Engine/__init__.py b/test/test_Engine/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_Engine/test_CapuletEngine.py b/test/test_Engine/test_CapuletEngine.py new file mode 100644 index 000000000..15db1a770 --- /dev/null +++ b/test/test_Engine/test_CapuletEngine.py @@ -0,0 +1,11 @@ +import unittest +from car_Module.components.engine import CapuletEngine + +class TestCapuletEngine(unittest.TestCase): + def test_check_needs_service_true_case(self): + capulet = CapuletEngine(current_mileage=30001,last_service_mileage=0) + self.assertTrue(capulet.needs_service()) + + def test_check_needs_service_false_case(self): + capulet = CapuletEngine(current_mileage=30000,last_service_mileage=0) + self.assertFalse(capulet.needs_service()) \ No newline at end of file diff --git a/test/test_Engine/test_SternmanEngine.py b/test/test_Engine/test_SternmanEngine.py new file mode 100644 index 000000000..f4ad83e26 --- /dev/null +++ b/test/test_Engine/test_SternmanEngine.py @@ -0,0 +1,11 @@ +import unittest +from car_Module.components.engine import SternmanEngine + +class TestSternmanEngine(unittest.TestCase): + def test_check_needs_service_true_case(self): + capulet = SternmanEngine(warning_light_is_on=True) + self.assertTrue(capulet.needs_service()) + + def test_check_needs_service_false_case(self): + capulet = SternmanEngine(warning_light_is_on=False) + self.assertFalse(capulet.needs_service()) \ No newline at end of file diff --git a/test/test_Engine/test_WilloughbyEngine.py b/test/test_Engine/test_WilloughbyEngine.py new file mode 100644 index 000000000..ce70fc823 --- /dev/null +++ b/test/test_Engine/test_WilloughbyEngine.py @@ -0,0 +1,11 @@ +import unittest +from car_Module.components.engine import WilloughbyEngine + +class TestWilloughbyEngine(unittest.TestCase): + def test_check_needs_service_true_case(self): + capulet = WilloughbyEngine(current_mileage=60001,last_service_mileage=0) + self.assertTrue(capulet.needs_service()) + + def test_check_needs_service_false_case(self): + capulet = WilloughbyEngine(current_mileage=60000,last_service_mileage=0) + self.assertFalse(capulet.needs_service()) \ No newline at end of file diff --git a/test/test_Tire/__init__.py b/test/test_Tire/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_Tire/test_Carrigan.py b/test/test_Tire/test_Carrigan.py new file mode 100644 index 000000000..bda8f3f9a --- /dev/null +++ b/test/test_Tire/test_Carrigan.py @@ -0,0 +1,11 @@ +import unittest +from car_Module.components.tire import CarriganTire + +class TestCarriganTire(unittest.TestCase): + def test_check_needs_service_true_case(self): + tire = CarriganTire([0,0.9,1,0.2]) + self.assertTrue(tire.needs_service()) + + def test_check_needs_service_flase_case(self): + tire = CarriganTire([0,0.1,0.1,0.2]) + self.assertFalse(tire.needs_service()) \ No newline at end of file diff --git a/test/test_Tire/test_Octoprime.py b/test/test_Tire/test_Octoprime.py new file mode 100644 index 000000000..0209106a5 --- /dev/null +++ b/test/test_Tire/test_Octoprime.py @@ -0,0 +1,11 @@ +import unittest +from car_Module.components.tire import OctoprimeTire + +class TestOctoprimeTire(unittest.TestCase): + def test_check_needs_service_true_case(self): + tire = OctoprimeTire([0.9,0.9,1,0.3]) + self.assertTrue(tire.needs_service()) + + def test_check_needs_service_flase_case(self): + tire = OctoprimeTire([0,0.1,0.1,0.2]) + self.assertFalse(tire.needs_service()) \ No newline at end of file diff --git a/test/test_car.py b/test/test_car.py deleted file mode 100644 index f5994670d..000000000 --- a/test/test_car.py +++ /dev/null @@ -1,188 +0,0 @@ -import unittest -from datetime import datetime - -from engine.model.calliope import Calliope -from engine.model.glissade import Glissade -from engine.model.palindrome import Palindrome -from engine.model.rorschach import Rorschach -from engine.model.thovex import Thovex - - -class TestCalliope(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 1) - current_mileage = 0 - last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - def test_engine_should_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 30001 - last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_engine_should_not_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 30000 - last_service_mileage = 0 - - car = Calliope(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - -class TestGlissade(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 1) - current_mileage = 0 - last_service_mileage = 0 - - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - def test_engine_should_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 60001 - last_service_mileage = 0 - - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_engine_should_not_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 60000 - last_service_mileage = 0 - - car = Glissade(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - -class TestPalindrome(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 5) - warning_light_is_on = False - - car = Palindrome(last_service_date, warning_light_is_on) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - warning_light_is_on = False - - car = Palindrome(last_service_date, warning_light_is_on) - self.assertFalse(car.needs_service()) - - def test_engine_should_be_serviced(self): - last_service_date = datetime.today().date() - warning_light_is_on = True - - car = Palindrome(last_service_date, warning_light_is_on) - self.assertTrue(car.needs_service()) - - def test_engine_should_not_be_serviced(self): - last_service_date = datetime.today().date() - warning_light_is_on = False - - car = Palindrome(last_service_date, warning_light_is_on) - self.assertFalse(car.needs_service()) - - -class TestRorschach(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 5) - current_mileage = 0 - last_service_mileage = 0 - - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - def test_engine_should_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 60001 - last_service_mileage = 0 - - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_engine_should_not_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 60000 - last_service_mileage = 0 - - car = Rorschach(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - -class TestThovex(unittest.TestCase): - def test_battery_should_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 5) - current_mileage = 0 - last_service_mileage = 0 - - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_battery_should_not_be_serviced(self): - today = datetime.today().date() - last_service_date = today.replace(year=today.year - 3) - current_mileage = 0 - last_service_mileage = 0 - - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - def test_engine_should_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 30001 - last_service_mileage = 0 - - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertTrue(car.needs_service()) - - def test_engine_should_not_be_serviced(self): - last_service_date = datetime.today().date() - current_mileage = 30000 - last_service_mileage = 0 - - car = Thovex(last_service_date, current_mileage, last_service_mileage) - self.assertFalse(car.needs_service()) - - -if __name__ == '__main__': - unittest.main()