chore: README updated with KATA description feat: added kata_the_lamp.py test: added test_the_lamp.py for testing kata

This commit is contained in:
Sandro Zimmermann 2026-03-02 18:45:55 +01:00
parent bc6f7e27aa
commit 515df4d452
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,13 @@
class Lamp:
def __init__(self, color: str):
self.color = color
self.on = False
def toggle_switch(self):
self.on = not self.on
def state(self):
if self.on:
return "The lamp is on."
return "The lamp is off."

View File

@ -0,0 +1,13 @@
from src.codewars.kata_the_lamp import Lamp
def test_lamp():
my_lamp = Lamp("Blue")
assert my_lamp.color == "Blue"
assert not my_lamp.on
assert my_lamp.state() == "The lamp is off."
my_lamp.toggle_switch()
assert my_lamp.state() == "The lamp is on."
my_lamp.toggle_switch()
assert my_lamp.state() == "The lamp is off."