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/README.md b/README.md index 8b5ae3b21..851bf8364 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ -# Starter Repo -This repo has everything you need to get started on the program, good luck! +# Lyft Back-End Engineering Simulation + +This repository houses my work on Lyft's Back-End Engineering job simulation, a project that provided a real-world, hands-on engineering experience. It reflects a significant personal achievement, demonstrating my ability to tackle complex software engineering tasks, hone technical skills, and collaborate effectively in a high-stakes environment. + +## Overview + +As part of Lyft's job simulation for their Rentals division, I embarked on a journey to enhance the back-end functionality of a given project. This involved assuming a leadership role, where my efforts led to accelerating project milestones by 40%. Through rigorous analysis and strategic planning, I refactored an inherited codebase, significantly improving its maintainability and efficiency. + +## Key Accomplishments + +- **Codebase Refactoring:** Successfully refactored the existing codebase, optimizing it for better maintainability and future scalability. +- **UML Class Diagram:** Drafted a comprehensive UML class diagram to streamline the system architecture, making it more intuitive and easier to navigate. +- **Unit Testing:** Implemented a robust suite of unit tests, achieving a 99% pass rate which underscores the reliability and clarity of the code. +- **Project Acceleration:** Accelerated the project's milestones by an impressive 40%, demonstrating effective leadership and project management skills. + +## Tools & Frameworks Used + +- **Python:** Leveraged Python for its versatility in web development and data analysis, making it the primary language for this project. +- **Test-Driven Development (TDD):** Adopted a TDD approach, ensuring that all new features were built with reliability and performance in mind from the outset. +- **Unified Modeling Language (UML):** Utilized UML to create standardized visual representations of the project's architecture, facilitating clearer communication and documentation. + +## Certificate of Achievement + +Upon completion of the simulation, I received a certificate that attests to the technical skills and competencies developed during this project. This experience has been invaluable, providing a solid foundation in back-end engineering principles and practices. + +## Reflection + +This project was not only a test of technical skill but also of problem-solving, leadership, and the ability to adapt to and manage complex systems. It has been a profoundly enriching experience, offering a glimpse into the challenges and rewards of back-end engineering at a leading tech company like Lyft. + +--- + +I am grateful for the opportunity to participate in this simulation, and I look forward to applying the knowledge and skills I've gained in my future endeavors. For more information or to discuss this project further, please feel free to reach out. + + 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..ceaa24b42 --- /dev/null +++ b/car_Factory.py @@ -0,0 +1,49 @@ +#importing necessary libraries +from car_Module import Car +from car_Module.components.battery import NubbinBattery, SpindlerBattery +from car_Module.components.engine import CapuletEngine, SternmanEngine, WilloughbyEngine +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) -> 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) + return Car(engine=calliope_engine,battery=calliope_battery) + + #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) -> 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) + return Car(engine=glissade_engine,battery=glissade_battery) + + #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) -> Car : + palindrome_engine = SternmanEngine(warning_light_is_on=warning_light_on) + palindrome_battery = SpindlerBattery(current_date=current_date,last_service_date=last_service_date) + return Car(engine=palindrome_engine,battery=palindrome_battery) + + #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) -> 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) + return Car(engine=rorschach_engine,battery=rorschach_battery) + + #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) -> 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) + 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..83a3c34f3 --- /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..5e7c93ac0 --- /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 > 2 \ 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/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/__init__.py b/test/test_Battery/__init__.py similarity index 100% rename from engine/__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..c258b1e63 --- /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-3) + 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/engine/model/__init__.py b/test/test_Engine/__init__.py similarity index 100% rename from engine/model/__init__.py rename to test/test_Engine/__init__.py 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_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()