Ejemplo n.º 1
0
	def test_unbroken_sleep(self):
		# Sleep from 8pm till 4am then 5am to 7am.
		# This should yield an 8 hour unbroken stretch

		# this "sleep set" is for Jan 1st.  The overnight records are from Jan 2nd, not 
		# part of this day, so the records need to be added outside the constructor.

		rec1 = SleepRecord(datetime(2016, 1, 1, 20, 0, 0), datetime(2016, 1, 2, 4, 0, 0))
		records = [ rec1 ]
		sut = SleepSet(records)

		rec2 = SleepRecord(datetime(2016, 1, 2, 5, 0, 0), datetime(2016, 1, 2, 7, 0, 0))
		records_overnight = [ rec2 ]
		sut.set_overnight_sleep_records(records_overnight)

		self.assertEqual(8.0, sut.get_unbroken_night_sleep_hrs())