commit 1550ea0cff3e8b8167a879dc85e217b5366a19a4
parent 69836fd998e1d7bf8cefd9c12607d115b63d07dc
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sun, 28 May 2023 21:52:49 +0200
[RED] Still red, but fixed error in test
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/thermostat.py b/thermostat.py
@@ -1,15 +1,25 @@
import unittest
+from datetime import datetime
class Thermostat:
+ def GetCurrentTime(self):
+ return int(datetime.now().strftime("%H"))
+
def GetCurrentRequiredTemperature(self):
return 10
+ def AddSetPoint(self, hour, temperature):
+ self.setPoint = (hour, temperature)
+
class TestableThermostat(Thermostat):
def __init__(self, hour):
self.hour = hour
+ def GetCurrentTime(self):
+ return hour
+
class ThermostatTests(unittest.TestCase):
def test_GivenNewThermostat_ThenRequiredTemperatureIs10(self):
@@ -21,5 +31,5 @@ class ThermostatTests(unittest.TestCase):
hour = 10
requiredTemperature = 30
thermostat = TestableThermostat(hour)
- thermostat.AddSetPoint(hour, temperature)
+ thermostat.AddSetPoint(hour, requiredTemperature)
self.assertEqual(thermostat.GetCurrentRequiredTemperature(), requiredTemperature)