Ejemplo n.º 1
0
	def test_output_metric_file(self):
		fifo.simulateCafeDay('fifo_tests/input_test3')
		with open('output_files/fifo_metric_output.json') as data_file:
			data = json.load(data_file)

		order1 = data[0]
		self.assertEqual(order1['order_id'],1)
		self.assertEqual(order1['start_time'], 0)
		self.assertEqual(order1['barista_id'], 1)
		self.assertEqual(order1['type'], 'affogato')
		self.assertEquals(order1['order_time'], 0)

		order2 = data[1]
		self.assertEqual(order2['order_id'],2)
		self.assertEqual(order2['start_time'], 1)
		self.assertEqual(order2['barista_id'], 2)
		self.assertEqual(order2['type'], 'tea')
		self.assertEqual(order2['order_time'], 1)

		order3 = data[2]
		self.assertEqual(order3['order_id'],3)
		self.assertEqual(order3['start_time'], 4)
		self.assertEqual(order3['barista_id'], 2)
		self.assertEqual(order3['type'], 'latte')
		self.assertEqual(order3['order_time'], 2)

		order4 = data[3]
		self.assertEqual(order4['order_id'],4)
		self.assertEqual(order4['start_time'], 7)
		self.assertEqual(order4['barista_id'], 1)
		self.assertEqual(order4['type'], 'tea')
		self.assertEqual(order4['order_time'], 2)
Ejemplo n.º 2
0
	def test_barista_both_available_at_same_time_two_orders_have_different_order_time(self):
		fifo.simulateCafeDay('fifo_tests/fifo_test2')
		with open('output_files/output_fifo.json') as data_file:
			data = json.load(data_file)

		order1 = data[0]
		self.assertEqual(order1['order_id'], 1)
		self.assertEqual(order1['start_time'], 1)
		self.assertEqual(order1['barista_id'], 1)

		order2 = data[1]
		self.assertEqual(order2['order_id'],2)
		self.assertEqual(order2['start_time'], 0)
		self.assertEqual(order2['barista_id'], 2)
Ejemplo n.º 3
0
	def test_both_baristas_busy(self):
		fifo.simulateCafeDay('fifo_tests/fifo_test5')
		with open('output_files/output_fifo.json') as data_file:
			data = json.load(data_file)

		order1 = data[0]
		self.assertEqual(order1['order_id'], 1)
		self.assertEqual(order1['start_time'], 0)
		self.assertEqual(order1['barista_id'], 1)

		order2 = data[1]
		self.assertEqual(order2['order_id'],2)
		self.assertEqual(order2['start_time'], 0)
		self.assertEqual(order2['barista_id'], 2)

		order2 = data[2]
		self.assertEqual(order2['order_id'],3)
		self.assertEqual(order2['start_time'], 3)
		self.assertEqual(order2['barista_id'], 1)
Ejemplo n.º 4
0
	def test_simulateCafeDay(self):
		profit, num_of_orders, percent_of_orders, average_wait_time, _ = fifo.simulateCafeDay('fifo_tests/input_test1')
		with open('output_files/output_fifo.json') as data_file:
			data = json.load(data_file)

		order1 = data[0]
		self.assertEqual(order1['order_id'],1)
		self.assertEqual(order1['start_time'], 0)
		self.assertEqual(order1['barista_id'], 1)

		order2 = data[1]
		self.assertEqual(order2['order_id'],2)
		self.assertEqual(order2['start_time'], 1)
		self.assertEqual(order2['barista_id'], 2)

		order3 = data[2]
		self.assertEqual(order3['order_id'],3)
		self.assertEqual(order3['start_time'], 4)
		self.assertEqual(order3['barista_id'], 2)

		order4 = data[3]
		self.assertEqual(order4['order_id'],4)
		self.assertEqual(order4['start_time'], 7)
		self.assertEqual(order4['barista_id'], 1)
Ejemplo n.º 5
0
	def test_BaristaNotAbleToProcessOrderUntilAfterTis100(self):
		profit, num_of_orders, percent_of_orders, average_wait_time, _ = fifo.simulateCafeDay('fifo_tests/input_test2')
		self.assertEquals(profit, 10)
		self.assertEquals(num_of_orders, 3)
		self.assertEquals(percent_of_orders, 0.6)
		self.assertEquals(average_wait_time, 16/float(3))
Ejemplo n.º 6
0
	def test_metrics(self):
		profit, num_of_orders, percent_of_orders, average_wait_time, _ = fifo.simulateCafeDay('fifo_tests/input_test1')
		self.assertEquals(profit, 12)
		self.assertEquals(num_of_orders, 4)
		self.assertEquals(percent_of_orders, 0.8)
		self.assertEquals(average_wait_time, 24/float(4))