from unittest import TestCase
from functions import divide, multiply

class TestFunction(TestCase):

	def test_divide_result(self):
		dividend = 15
		divisor = 3
		expected_result = 5.0
		self.assertAlmostEqual(divide(dividend, divisor), expected_result, delta=0.0001)

	def test_divide_negative(self):
		dividend = 15
		divisor = -3
		expected_result = -5.0
		self.assertAlmostEqual(divide(dividend, divisor), expected_result, delta=0.0001)

	def test_divide_zero(self):
		dividend = 0
		divisor = 5
		expected_result = 0
		self.assertEqual(divide(dividend, divisor), expected_result)

	def test_divide_error_on_zero(self):
		# self.assertRaises(ValueError, lambda: divide(25,0))
		with self.assertRaises(ValueError):
			divide(25, 0)

	def test_multiply_empty(self):
		with self.assertRaises(ValueError):
			multiply()

	def test_multiple_single_value(self):
		expected_result = 15
		self.assertEqual(multiply(expected_result), expected_result)

	def test_multiply_zero(self):
		expected_result = 0
		self.assertEqual(multiply(expected_result), expected_result)

	def test_multiply_result(self):
		inputs = (3, 4, 2)
		expected_result = 24
		# Note *inputs which returns elements of the tuple
		self.assertEqual(multiply(*inputs), expected_result)

	def test_multiply_result_with_zero(self):
		inputs = (3, 0, 2)
		expected_result = 0
		# Note *inputs which returns elements of the tuple
		self.assertEqual(multiply(*inputs), expected_result)

	def test_multiply_negative(self):
		inputs = (3, 4, -2)
		expected_result = -24
		# Note *inputs which returns elements of the tuple
		self.assertEqual(multiply(*inputs), expected_result)

	def test_multiply_floats(self):
		inputs = (3.0, 4)
		expected_result = 12.0
		# Note *inputs which returns elements of the tuple
		self.assertEqual(multiply(*inputs), expected_result)

