Ejemplo n.º 1
0
	def test_less_than_operator(self):
		e1 = Event(5.0, 6.0, 'Monday', 1)
		e2 = Event(6.0, 7.0, 'Tuesday', 1)
		assert(not(e2 < e1))
		assert(e1 < e2)
		e2.start_time = 5.0
		assert(not(e2 < e1))
		assert(not(e1 < e2))
Ejemplo n.º 2
0
	def test_greater_than_operator(self):
		e1 = Event(5.0, 6.0, 'Monday', 1)
		e2 = Event(6.0, 7.0, 'Tuesday', 1)
		assert(e2 > e1)
		assert(not(e1 > e2))
		e2.start_time = 5.0
		assert(not(e2 > e1))
		assert(not(e1 > e2))
Ejemplo n.º 3
0
	def test_zone_ownership(self):
		e = Event(1.0, 2.0, 'Monday', 1)
		self.assertEqual(e.owner, 1)

		e.owner = 2
		self.assertEqual(e.owner, 2)

		with self.assertRaises(ValueError):
			e.owner = 'T'
Ejemplo n.º 4
0
	def test_days(self):
		e = Event(1.0, 2.0, 'Monday', 1)
		self.assertEqual(e.day, 'Monday')
		e.day = 'Tuesday'
		self.assertEqual(e.day, 'Tuesday')
		e.day = 'Wednesday'
		self.assertEqual(e.day, 'Wednesday')
		e.day = 'Thursday'
		self.assertEqual(e.day, 'Thursday')
		e.day = 'Friday'
		self.assertEqual(e.day, 'Friday')
		e.day = 'Saturday'
		self.assertEqual(e.day, 'Saturday')
		e.day = 'Sunday'
		self.assertEqual(e.day, 'Sunday')

		with self.assertRaises(ValueError):
			e.day = 'Funday'
		self.assertEqual(e.day,'Sunday')
 def test_insert_event_into_schedule(self):
     s = Schedule()
     e1 = Event(1.00, 2.00, 'Monday', 1)
     s.insert_event('Monday', e1)
     self.assertEqual(len(s.mySchedule['Monday']), 1)
Ejemplo n.º 6
0
            self.mySchedule[myDay].append(myEvent)
            self.mySchedule[myDay].sort()
        else:
            raise KeyError("That is an incorrect key for this structure")

    def get_event_at_day(self, day):
        if day in self.mySchedule.keys():
            return self.mySchedule[day]
        else:
            print("Incorrect day was specified")


########################## Testing for the Schedule class ##########################
if __name__ == "__main__":
    test = Schedule()
    testEvent = Event(1.00, 2.00)
    testEvent2 = Event(5.00, 6.00)
    testEvent3 = Event(8.00, 10.50)
    testEvent4 = Event(2.00, 4.00)
    testEvent5 = Event(3.00, 3.15)
    testEvent6 = Event(7.00, 8.00)
    testEvent7 = Event(2.00, 10.50)
    testEvent8 = Event(18.00, 19.60)
    testEvent9 = Event(23.00, 23.59)
    testEvent10 = Event(22.00, 22.15)
    test.insert_event('Monday', testEvent)
    test.insert_event('Monday', testEvent2)
    test.insert_event('Monday', testEvent3)
    test.insert_event('Tuesday', testEvent4)
    test.insert_event('Tuesday', testEvent5)
    test.insert_event('Friday', testEvent6)
Ejemplo n.º 7
0
	def test_create_event(self):
		e = Event(1.0, 2.0, 'Monday', 1)
		self.assertEqual(e.start_time, 1.0)
		self.assertEqual(e.stop_time, 2.0)
		self.assertEqual(e.day, 'Monday')
Ejemplo n.º 8
0
	def test_create_event_with_bad_changed_end_time(self):
		e = Event(2.0, 3.0, 'Friday', 1)
		with self.assertRaises(ValueError):
			e.stop_time = 1.0
		with self.assertRaises(ValueError):
			e.stop_time = 200.00
Ejemplo n.º 9
0
	def test_create_event_bad_initial_end_time(self):
		with self.assertRaises(ValueError):
			e = Event(2.0,1.0, 'Wednesday', 1)
		with self.assertRaises(ValueError):
			r = Event(4.0,24.00, 'Thursday', 1)
Ejemplo n.º 10
0
	def test_create_event_bad_changed_start_time(self):
		e = Event(1.0, 2.0, 'Tuesday', 1)
		with self.assertRaises(ValueError):
			e.start_time = 3.0
		with self.assertRaises(ValueError):
			e.start_time = 24.0
Ejemplo n.º 11
0
	def test_create_event_bad_initial_start_time(self):
		with self.assertRaises(ValueError):
			e = Event(3.0, 2.0, 'Sunday', 1)
		with self.assertRaises(ValueError):
			r = Event(24.0, 3.0, 'Sunday', 1)